【发布时间】:2014-03-20 01:33:44
【问题描述】:
我想将 ImageView 放在另一个视图的顶部(上方),该视图使用宽度和高度的百分比从 SurfaceView 派生。但不知道如何实现这一目标。有什么帮助吗?
到目前为止,这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<MyOwnView
android:id="@+id/my_own_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".20"
android:contentDescription="@string/imageview_description"
android:src="@drawable/background_picture" />
</RelativeLayout>
这就是我想要的:
【问题讨论】:
-
确实,我做到了。但这是完全不同的场景,因为有两个元素使用了 30% 和 70% 的空间。在我的场景中,一种观点落后于另一种观点。我从该帖子中获取了我的 ImageView 的 XML 布局。但是没有用。
标签: android android-layout layout android-relativelayout