无法将视图放在线层的底部
您好使用线性布局,其中包含一些文本视图和图像视图,并且它组织得很好,但是我想添加一个横幅广告,但是当我添加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
<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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用这个包裹您的建议。然后将adview Gravity设置为底部|中心
Wrap your AdView with this. And then set AdView Gravity to bottom|center