【发布时间】:2015-06-30 15:28:32
【问题描述】:
我对安卓很陌生。我正在尝试在应用程序底部添加一个 admob 横幅,实际上是在两个活动中。我认为 Linearlayout 不是正确的做法。
- 所以请帮我将 Linearlayout 转换为 RelativeLayout。
同样在运行应用程序时,仅显示 activity_entry.xml 示例-google-banner。 view_home.xml 横幅只显示静态空白。
- 如何使横幅智能?我的意思是我希望它仅在要显示横幅时显示,而不是作为静态空白区域显示。
activity_entry.xml
<?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:orientation="vertical">
<include layout="@layout/view_toolbar"/>
<fragment
android:id="@+id/entry_fragment"
class="net.etuldan.sparss.fragment.EntryFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
android:layout_gravity="center_horizontal">
</com.google.android.gms.ads.AdView>
view_home.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:showIn="@layout/activity_home"
android:weightSum="1">
<include layout="@layout/view_toolbar"/>
<fragment
android:id="@+id/entries_list_fragment"
android:name="net.etuldan.sparss.fragment.EntriesListFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
android:layout_gravity="center_horizontal">
</com.google.android.gms.ads.AdView>
【问题讨论】:
标签: android xml android-layout admob adbannerview