【问题标题】:Custom Relative Layout with ads带有广告的自定义相对布局
【发布时间】:2018-06-05 17:05:28
【问题描述】:

我正在尝试制作这样的布局,但是如果从 tom 添加填充我的广告视图变小我做错了什么可以请有人帮我不擅长布局我应该使用相对布局还是通过线性布局我想在各种屏幕尺寸上工作请指导我如何制作像这样的精确布局

这是我的代码

    <?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】:

    将填充添加到您的父线性布局

    android:padding="16dp"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-25
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多