Not able to put view in bottom of linearlayout

34 Views Asked by At

Hello im using linear layout which contains some text view and a image view and it is organized well but i want to add a banner ad but when i add layout_gravity"bottom" its not going to the bottom of the screen

i have tried to add android:layout_weight="1" but it didnt help me much

enter image description here

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="@color/dark_grey"
    android:baselineAligned="false"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="horizontal"
        tools:ignore="UseCompoundDrawables">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="10dp"
            android:text="About me"
            android:textColor="@color/white"
            android:textSize="30sp"
            android:textStyle="bold|normal" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginStart="5dp"
            android:layout_marginTop="13dp"
            android:contentDescription="@string/todo"
            android:src="@drawable/ic_baseline_about_24" />

    </LinearLayout>


    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="15dp"
        android:layout_marginTop="30dp"
        android:layout_marginEnd="10dp"
        android:text="Hello dog lover, I would like to thank you so much for using my app. It means a lot to me."
        android:textAlignment="viewStart"
        android:textColor="@color/white"
        android:textSize="17sp"
        android:textStyle="normal|bold" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="15dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="10dp"
        android:text="Basically, I'm a dog owner who wants to hear Coco (my dog offcource) howl, and for me, this audio worked like magic. Hopefully, my app will work for you too. "
        android:textAlignment="viewStart"
        android:textColor="@color/white"
        android:textSize="17sp"
        android:textStyle="normal|bold" />

    <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView_about"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:layout_marginTop="10dp"
        android:layout_weight="1"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111" />


</LinearLayout>
1

There are 1 best solutions below

4
On
<LinearLayout
    android:layout_width="match_parent"
    android:layout_weight="1"
    android:layout_height="0dp">

</LinearLayout>

Wrap your AdView with this. And then set AdView Gravity to bottom|center