I'm triying to put an ImageView in bottom right of LinearLayout .... I wrote the code as bellow :
style.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="90dp"
android:background="@drawable/my_background"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:src="@drawable/my_small_image" />
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
This code results in the ImageView 'my_small_image' at the bottom right, but I need it in the bottom left. Anyone have any ideas about this?
I hope somebody here can help me.
Best regards and thanks in advance, Fadel.
You can set the layout_height="0dp" of your header, footer and ScrollView and define a layout_weight .
This constant was deprecated in API level 28.
To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout). Then set the android:layout_weight of each view to "1" .
Android LinearLayout organizes elements along a single line. We can specify whether that line is vertical or horizontal using android:orientation . The orientation is horizontal by default.
Using LinearLayout
is possible:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:orientation="vertical">
<!-- other elements in linear layout here -->
<!-- making a RelativeLayout un-desirable -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:scaleType="fitEnd"
android:src="@drawable/your_image" />
</LinearLayout>
This will position the image at the center-bottom, for bottom-right use
android:layout_gravity="right"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With