【问题标题】:Add fragment under existing views在现有视图下添加片段
【发布时间】:2014-03-17 10:41:46
【问题描述】:

我有一个包含 AdView 视图的 fragmentActivity

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativePrincipal"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

 <com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/banner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    ads:adSize="BANNER"
    ads:adUnitId="**********" />

</RelativeLayout>

这个 FragmentActivity 将包含几个片段,我会在每个片段中显示 AdView。有一种方法可以将片段“置于”AdView 之下,或者我需要为我将在 FragmentActivity 中使用的每个片段添加 AdView?

【问题讨论】:

    标签: android view fragment admob


    【解决方案1】:

    有一种方法可以将片段“置于”AdView 之下...?

    当然,你可以这样做:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
     <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/banner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="**********" />
    
     <RelativeLayout 
        android:id="@+id/relativePrincipal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/banner" >
    
    </RelativeLayout>
    

    【讨论】:

    • 当然,这很简单:) 我需要睡一会儿!谢谢
    • 那是肯定的!不要忘记接受答案。很高兴帮助了你 ;)
    猜你喜欢
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多