2015-10-14 82 views
0

我想在其他图像视图或视图上显示一个Imageview。如下图所示。显示一个imageview高于其他?

enter image description here

为了实现这一目标,我写代码

<LinearLayout 
     android:id="@+id/linear_restaurent_info" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight=".35" 
     android:background="@color/white" 
     android:orientation="vertical" > 

     <FrameLayout 
      android:id="@+id/framelayout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 

      <ImageView 
       android:id="@+id/frameImage" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_gravity="start" 
       android:src="@drawable/demo_pics" /> 

      <ImageView 
       android:id="@+id/imageView_restaurent_pic" 
       android:layout_width="70dp" 
       android:layout_height="55dp" 
       android:layout_gravity="bottom" 
       android:layout_marginBottom="-20dp" 
       android:layout_marginLeft="10dp" 
       android:src="@drawable/icon_search" /> 
     </FrameLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight=".15" 
     android:orientation="vertical" > 

     <!-- android:background="@color/Orange" --> 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

      <TextView 
       android:id="@+id/restaurent_name" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="10dp" 
       android:text="Laziz" 
       android:textColor="@color/list_restaurent_name_text" /> 

      <TextView 
       android:id="@+id/restaurent_address" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/restaurent_name" 
       android:layout_below="@+id/restaurent_name" 
       android:layout_marginTop="10dp" 
       android:singleLine="true" 
       android:paddingLeft="10dp" 
       android:text="151 Radford Road, Nottingham, NG7" 
       android:textColor="@color/list_restaurent_name_text" /> 
     </RelativeLayout> 
    </LinearLayout> 

但不能达到esired之一。

我的输出看起来如下;任何建议表示赞赏。

enter image description here

回答

0

你在这里。您需要调整一些这里的代码`

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="300dp" 
    android:background="#FFFFFF"> 

    <ImageView 
     android:id="@+id/imgCake" 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     android:src="@drawable/image_cake" /> 

    <ImageView 
     android:layout_width="150dp" 
     android:layout_height="100dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_marginBottom="55dp" 
     android:src="@drawable/img_laziz" 
     android:id="@+id/imgLaziz" /> 


    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Laziz" 
     android:textColor="#000000" 
     android:textSize="28sp" 
     android:layout_below="@+id/imgCake" 
     android:layout_toRightOf="@+id/imgLaziz" 
     android:layout_toEndOf="@+id/imgLaziz" 
     android:layout_marginLeft="52dp" 
     android:layout_marginStart="52dp" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="151 Radford Rasd Nott" 
     android:textColor="#000000" 
     android:textSize="18sp" 
     android:layout_below="@+id/textView" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 

</RelativeLayout> 

` enter image description here

0

有你的答案:Placing/Overlapping(z-index) a view above another view in android 不能使用的LinearLayout这一点,但你可以使用一个FrameLayout里。在FrameLayout中,z索引由项目的添加顺序定义。学分@kcoppock

+0

我已经使用的FrameLayout。但我无法解决实际输出的组合。 –

+0

@shihab_returns你的代码的第二部分(我的意思是第二个线性布局)呢?问题可能在那里... – tonakriz

0

我想你应该尝试相对布局吧...因为通过使用它,你可以把机器人:layout_above =“@ + ID/yourImageIdwhichYouWantToAboveFromAnImage” 我希望通过这个您的问题正在得到解决!

0

你必须使用RelativeLayout,让你多properties关于定位你的看法。因此,我认为你所要做的就是改变视图的体系结构,以便正确地重新对其进行重新排列。