【发布时间】:2013-05-13 01:18:45
【问题描述】:
想办法解决这个小问题。
下方左侧是我尝试为应用实现的视图示例。右侧是我最终得到的视图。
在我的 xml 模型中,我决定使用 RelativeLayout,但我无法让 TextView 在顶部和底部视图之间居中。
作为参考,这里是我的 xml 代码的表示:
<RelativeLayout
android:layout_width:"match_parent"
android:layout_height:"wrap_content">
<ImageView
android:id="@+id/BlackImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_alightParentTop="true"
android:layout_centerHorizontal="true"/>
<ImageView
android:id="@+id/RedImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_below="@+id/BlackImage"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/BlackImage"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
知道我缺少什么,或者如何改变以获得我想要的吗?
【问题讨论】:
-
我想我会尝试使用
FrameLayout,因为RelativeLayout更适合用于沿边缘对齐的视图。无论如何,您可以尝试负边距或填充。 -
试试下面的链接希望对你有帮助:- stackoverflow.com/questions/9539772/…> stackoverflow.com/questions/15976292/…> stackoverflow.com/questions/10195557/…>
标签: android android-layout android-relativelayout android-view