Android 在其他图像视图之上显示一个图像视图?
我想在其他Imageview或view上显示一个Imageview。如下图所示 为了实现这一点,我编写了代码Android 在其他图像视图之上显示一个图像视图?,android,android-framelayout,Android,Android Framelayout,我想在其他Imageview或view上显示一个Imageview。如下图所示 为了实现这一点,我编写了代码 <LinearLayout android:id="@+id/linear_restaurent_info" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight=".35"
<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>
但无法达到预期的效果
我的输出如下所示。如有任何建议,我们将不胜感激
这是你的答案:
不能为此使用线性布局,但可以使用框架布局。在FrameLayout中,z索引由项的添加顺序定义。归功于@kcopock我认为你应该尝试相对布局……因为通过使用它,你可以将android:layout_置于=“@+id/YourImageId,你希望它高于Animage” 我希望通过使用这个,你的问题能得到解决 您必须使用它,它为您提供了许多有关视图定位的信息。
因此,在我看来,您所要做的就是更改视图的体系结构,以便正确地重新调整它们 给你。你需要在这里调整一些代码`
`
我已经在使用FrameLayout。但我无法解决实际输出的组合。@shihab_返回代码的第二部分(我指的是第二个线性布局)如何?问题可能在那里。。。
<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>