如何创建一个像这样的android布局?
答
可以简单地用一个的RelativeLayout并相应地放置所有元素到其他。
喜欢的东西:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/centered_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<LinearLayout
android:id="@+id/bottom_right_container"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- the stuff bottom right -->
</LinearLayout>
</RelativeLayout>
谢谢,但如何在ImageView的中间的@ + ID/centered_text? – 2014-12-13 14:41:05
知道了!我已经在另一个相对布局中添加了imageview和textview,并给出了一个固定的高度 – 2014-12-13 14:45:50
@OssamaBenallouch你应该避免固定的高度。查看ImageView和RelativeLayout参数的scaleTypes(如用于TextView的centerInParent)。这些组合应该允许更好的缩放。 – zgc7009 2014-12-13 15:56:06