[英]Keep text at the bottom with LinearLayout and ScrollView
我正在嘗試構建一個具有多個選項的菜單,並且在頁面底部,應該有一個文本。 如果圖標不合適,頁面應該滾動。 文本與底部的距離應為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>
到目前為止,除我無法使文字堅持到底這一事實外,其他所有內容都工作正常。 感覺取決於上面的LinearLayout。 我可以為最后一個布局(包含文本的布局)設置邊距,但是數字可能是一個猜測,這不是我想要的。
有人可以幫我嗎?謝謝!!
我認為如果將TextView' outside of
ScrollView TextView' outside of
更好. Solution can be multiple. On simple one can be Using a
. Solution can be multiple. On simple one can be Using a
. 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.