Reputation: 449
I am trying to build a menu with multiple options and, at the bottom of the page, there should be a text. The page should scroll in case the icons don't fit. The text should be at around 6 dp distance from the bottom and some kind of minimum distance from the icons so that they don't overlay if the screen has a different configuration (see figure)
So far, I have this configuration:
< 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>
So far everything works fine except that fact that I can't make the text stick to the bottom. It feels dependent on the above LinearLayout. I could set a margin to the last layout (the one containing the text), but the number would be a guess, which is not what I want.
Can anyone help me with this?Thanks!!
Upvotes: 0
Views: 859
Reputation: 21043
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>
Upvotes: 2