简体   繁体   English

无法将视图放在线性布局的底部

[英]Not able to put view in bottom of linearlayout

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你好,我正在使用包含一些文本视图和图像视图的线性布局,它组织得很好,但我想添加一个横幅广告,但是当我添加layout_gravity"bottom"时,它不会到达屏幕底部

i have tried to add android:layout_weight="1" but it didnt help me much我试图添加android:layout_weight="1"但它对我帮助不大

在此处输入图像描述

<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>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_weight="1"
    android:layout_height="0dp">

</LinearLayout>

Wrap your AdView with this.用这个包装你的 AdView。 And then set AdView Gravity to bottom|center然后将 AdView Gravity 设置为 bottom|center

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM