2015-10-14 3 views
0

Я хочу показать одно изображение выше другого изображения или вида. Как показано ниже.показать одно изображение выше других?

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-index определяется порядком, в котором элементы добавляются. Кредиты @kcoppock

+0

я уже использую FrameLayout. но я не могу решить комбинацию фактического вывода. –

+0

@shihab_returns Что относительно этой второй части вашего кода (я имею в виду эту вторую линейную компоновку)? Проблема может быть там ... – tonakriz

0

я думаю, вы должны попробовать Относительный макет для него ... потому что с его помощью вы можете поставить андроид: layout_above = «@ + идентификатор/yourImageIdwhichYouWantToAboveFromAnImage» я надеюсь, что с помощью этого проблему решаемой.!

0

Вы должны использовать RelativeLayout, что дает вам много properties о размещении ваших взглядов. Итак, все, что вам нужно сделать, по моему мнению, состоит в том, чтобы изменить архитектуру вашего представления, чтобы правильно их перестроить.

Смежные вопросы