我试图在标签布局的顶部对齐广告布局,我没有太多的运气。它似乎被卡在底部对齐。我已经配置了标签布局,所以标签在屏幕的底部:
<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:id="@+id/adLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="0dp"
/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="23dp"
android:background="@drawable/tab_bg_selector"
android:layout_weight="0"
/>
</LinearLayout>
</TabHost>
更新:我修复了它,我忘记了我在代码中设置对齐,像这样:
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
一旦我改变ALIGN_PARENT_BOTTOM为ALIGN_PARENT_TOP,它工作了
我不太明白你的布局结构但我明白的是你想在屏幕顶部显示广告为此我修改了你的代码
<?xml version="1.0" encoding="utf-8"?>
<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">
<RelativeLayout android:id="@+id/adLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentTop="true">
</RelativeLayout>
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:background="@drawable/tab_bg_selector"
android:layout_alignParentBottom="true" android:layout_weight="0" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:padding="0dp"
android:layout_below="@id/adLayout" android:layout_above="@android:id/tabs"/>
</RelativeLayout>
</TabHost>