2015-10-14 84 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關於定位你的看法。因此,我認爲你所要做的就是改變視圖的體系結構,以便正確地重新對其進行重新排列。