如何在android中的nestedscrollview中设置横幅广告

时间:2018-05-30 07:29:16

标签: android-layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
xmlns:ads="http://schemas.android.com/apk/res-auto"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_scrolling1">

 <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/text_margin"
        android:text="@string/large_text" />
</android.support.v4.widget.NestedScrollView>

如何在Android中的nestedscrollview设置横幅广告?

1 个答案:

答案 0 :(得分:0)

NestedScrollView只能有一个孩子,你的有两个孩子。只需使用LinearLayout作为滚动视图的单个子项,并在那里添加孩子。

相关问题