无法将视图放在线层的底部

发布于 2025-01-23 21:29:18 字数 3322 浏览 2 评论 0原文

您好使用线性布局,其中包含一些文本视图和图像视图,并且它组织得很好,但是我想添加一个横幅广告,但是当我添加layout_gravity“ bottons”时,它不会进入底部屏幕

我尝试添加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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏闹i 2025-01-30 21:29:18
<LinearLayout
    android:layout_width="match_parent"
    android:layout_weight="1"
    android:layout_height="0dp">

</LinearLayout>

用这个包裹您的建议。然后将adview Gravity设置为底部|中心

<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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文