代码之家  ›  专栏  ›  技术社区  ›  andrew

FrameLayout而不是RelativeLayout

  •  0
  • andrew  · 技术社区  · 12 年前

    我有一个FrameLayout,底部有ScrollView和AdView横幅。 我认为有一种方法可以删除包含ScrollView和AdView的RelativeLayout,并保持当前的UI,但我无法确定如何做到这一点。

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg"
    tools:context="">
    
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/adView"
            android:layout_alignParentTop="true">
    
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
    
                <!-- A LOT of stuff -->
    
            </RelativeLayout>
        </ScrollView>
    
        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            ads:adSize="BANNER"
            ads:adUnitId="" />
    
    </RelativeLayout>
    </FrameLayout>
    
    2 回复  |  直到 12 年前
        1
  •  0
  •   Code-Apprentice    12 年前

    您可以删除 FrameLayout RelativeLayout 。事实上,您应该考虑使用 LinearLayout 作为根元素。

        2
  •  0
  •   issamux    12 年前

    试试看:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </RelativeLayout>
    </ScrollView>
    
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adSize="BANNER"
        ads:adUnitId="" />
    
    </FrameLayout>