繁体   English   中英

Android布局总是在tabwidget上方获取framelayout

[英]android layout get framelayout always above tabwidget

以下布局用于显示tabcontent上的视图。 但是,当出现admob时,framelayout会降低,从而使tabwidget出现在前面。 我怎么能总是在tabwidget上方设置frameLayout? 或相同,位于框架布局下方的tabwidget。 谢谢

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              >


      <com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="xxx"
                         ads:adSize="SMART_BANNER"
                         ads:testDevices="TEST_EMULATOR, xxx"
                         ads:loadAdOnCreate="true"/>   

<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

      <RelativeLayout       
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/mainLayout">


        <LinearLayout  
            android:id="@+id/mainLayout"
            android:orientation="vertical"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            >

                    <FrameLayout 
                        android:id="@android:id/tabcontent"
                        android:layout_width="fill_parent" 
                        android:layout_height="0dip"
                        android:layout_weight="1" 
                        android:scrollbars="none">
                    </FrameLayout>

            <TabWidget 
                android:id="@android:id/tabs"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content"
                android:layout_weight="0"/>

        </LinearLayout>         
    </RelativeLayout>
</TabHost> 

</LinearLayout>

在此处输入图片说明

我在您的布局中看到了两个可能导致此问题的问题。 首先,您的TabHost的layout_height不应为父代。 如果您希望它占用布局中的剩余空间(所有内容都不会被广告占用),请像使用FrameLayout一样将高度设置为0dip并将layout_weight为1。 另外,看起来您在RelativeLayout中嵌套了LinearLayout,而其中之一不是必需的。 对于您正在尝试的操作,我将消除RelativeLayout。 您可能还想摆脱TabWidget上的layout_weight属性。 将“帧”设置为1表示您希望它拉伸以填充父级中剩余的所有空间,并应为您提供所需的结果。 小部件的重量可能是造成重叠的原因。 希望这可以帮助。

应该是这样...

<TabHost>start

    <LinearLayout>start

        <com.google.ads.AdView
            start
            end />

        <FrameLayout>start

            <LinearLayout>start
            <LinearLayout>end

        </FrameLayout>end

        <TabWidget>start
        </TabWidget>end

    </LinearLayout>end

</TabHost>end

如果您想让Google用不同的选项卡添加更改,则上述方法是最好的,但是如果您不希望这样做,则只需这样做。...

<LinearLayout>start

    <com.google.ads.AdView
        start
        end />

    <TabHost>start

        <LinearLayout>start

            <FrameLayout>start

                <LinearLayout>start
                <LinearLayout>end

            </FrameLayout>end

            <TabWidget>start
            </TabWidget>end

        </LinearLayout>end

    </TabHost>end

</LinearLayout>end

还要将标签小部件设置为android:layout_marginBottom =“-4dp”以防万一。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM