简体   繁体   English

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

[英]android layout get framelayout always above tabwidget

Following layout is used to show views on tabcontent. 以下布局用于显示tabcontent上的视图。 However, when admob appears, framelayout goes down getting tabwidget on front. 但是,当出现admob时,framelayout会降低,从而使tabwidget出现在前面。 How could I set frameLayout always above tabwidget?? 我怎么能总是在tabwidget上方设置frameLayout? or the same, tabwidget below framelayout. 或相同,位于框架布局下方的tabwidget。 Thank you 谢谢

<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>

在此处输入图片说明

I see two issues in your layout that could be causing this. 我在您的布局中看到了两个可能导致此问题的问题。 First, the layout_height of your TabHost should not be fill parent. 首先,您的TabHost的layout_height不应为父代。 If you want it to take up the remaining space in your layout (everything not taken by the ad), set the height to 0dip and the layout_weight to 1, like you did with your FrameLayout. 如果您希望它占用布局中的剩余空间(所有内容都不会被广告占用),请像使用FrameLayout一样将高度设置为0dip并将layout_weight为1。 Also, it looks like you have a LinearLayout nested in a RelativeLayout, one of which isn't necessary. 另外,看起来您在RelativeLayout中嵌套了LinearLayout,而其中之一不是必需的。 For what you're trying, I would eliminate the RelativeLayout. 对于您正在尝试的操作,我将消除RelativeLayout。 You also may want to get rid of the layout_weight attribute on the TabWidget. 您可能还想摆脱TabWidget上的layout_weight属性。 Setting the Frame to 1 indicates that you want it to stretch to fill all the space remaining in the parent, and should give you the desired result. 将“帧”设置为1表示您希望它拉伸以填充父级中剩余的所有空间,并应为您提供所需的结果。 The widget's weight may be what's causing the overlap. 小部件的重量可能是造成重叠的原因。 Hope this helps. 希望这可以帮助。

It should be like so... 应该是这样...

<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

If you want to have the google adds change with the different tabs then the above way is best, but if you do not then just make it like this.... 如果您想让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

Also set the tab widget to android:layout_marginBottom="-4dp" just in case. 还要将标签小部件设置为android:layout_marginBottom =“-4dp”以防万一。

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

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