我正在尝试构建一个包含多个选项的菜单,并且在页面底部应该有一个文本。页面应滚动以防图标不合适。文本应距离底部约6 dp,距图标最小距离,以便在屏幕具有不同配置时不会叠加(见图)
到目前为止,我有这样的配置:
< ScrollView xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: app = "http://schemas.android.com/apk/res-auto"
xmlns: tools = "http://schemas.android.com/tools"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
tools: context = ".MainMenu" >
<RelativeLayout
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: layout_margin = "5dp"
android: gravity = "center_horizontal" >
<LinearLayout
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical" >
<LinearLayout
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: layout_marginTop = "20dp"
android: orientation = "horizontal" >
/// More linear layouts
<
/LinearLayout> <
/LinearLayout>
<
/RelativeLayout>
<!--</android.support.constraint.ConstraintLayout>-->
<
/ScrollView>
&#13;
到目前为止,一切正常,但事实是我无法将文字粘在底部。它感觉依赖于上面的LinearLayout。我可以设置一个边距到最后一个布局(包含文本的那个),但数字是猜测,这不是我想要的。
任何人都可以帮我吗?谢谢!!
答案 0 :(得分:1)
I think its better if you just put TextView' outside of
ScrollView. Solution can be multiple. On simple one can be Using a
RelativeLayout` .
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/txt"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Your content goes here-->
</LinearLayout>
</ScrollView>
<TextView
android:id="@+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="TextView"
android:textSize="24sp" />
</RelativeLayout>