自定义相对布局与广告

问题描述 投票:1回答:1

我正在尝试制作这样的布局,但是如果从我的广告视图添加填充变小,我做错了可以有人请帮助我不好布局我应该使用相对布局还是通过线性布局我希望在各种屏幕尺寸上工作它请指导我如何制作像这一个this is layout i want to make的精确布局

这是我的代码

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40sp"
        android:layout_marginTop="40dp"
        android:text="the End"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:gravity="center"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn_close"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="start" />



        <Button
            android:id="@+id/btn_play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="close" />

    </LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:gravity="center|bottom"
    android:layout_height="match_parent">

    <com.google.android.gms.ads.NativeExpressAdView
        android:id="@+id/nativeAd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="280x250"
        ads:adUnitId="ca-app-pub-394859312"/>

    <com.google.android.gms.ads.AdView
        android:id="@+id/bannerAd"
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/banner_id">
    </com.google.android.gms.ads.AdView>
</LinearLayout>


</LinearLayout>
android android-layout android-linearlayout android-relativelayout
1个回答
0
投票

将填充添加到父linearLayout

android:padding="16dp"
© www.soinside.com 2019 - 2024. All rights reserved.