android "layout_alignParentBottom" in relative layout
17,001
Solution 1
this solution worked for me
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFF00"
android:minHeight="100dp"
android:orientation="horizontal"
android:layout_gravity="bottom"
>
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textColor="#000000"
android:background="#FF0000"
android:text="Hello World"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="bottom|right"
android:text="button"/>
</FrameLayout>
Solution 2
this one fast one screen
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:background="#FFFF00"
android:minHeight="100dp" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="button" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/button1"
android:background="#000000"
android:text="TextView" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:background="#000000"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
Solution 3
just for try, can you double the min size of your layout and try it again? or maybe you can set a fix the hight of the layout and change it dynamically from the code when needed.
Author by
Buda Gavril
Updated on July 24, 2022Comments
-
Buda Gavril almost 2 years
So, I have this layout:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FFFF00" android:minHeight="100dp" android:layout_gravity="bottom" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:textColor="#000000" android:background="#FF0000" android:text="Hello World" /> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentRight="true" android:text="button"/> </RelativeLayout>
and this is how it looks:
but if I add
android:layout_alignParentBottom="true"
to the button here is how it looks:- Can someone please explain me this behavior?
- How to put my button at the bottom without resizing the yellow layout and without adding thousand of layouts for workarounds?
-
Buda Gavril about 12 yearsusing your code it makes my layout to cover all the screen because you've used android:layout_height="fill_parent" and I want that my layout to keep it's height as seen in my first screenshot
-
Buda Gavril about 12 yearsso I want my layout look like my first image, except that my button should be aligned to bottom.
-
Android about 12 yearsthis one you give size moer button to change
-
Buda Gavril about 12 yearsthis is not working because it doesn't keep into account minHeight from main relative layout