Выровняйте макет объявления сверху - PullRequest
0 голосов
/ 24 декабря 2011

Я пытаюсь выровнять рекламный макет в верхней части макета вкладки, и мне не везет. Кажется, застрял, выравнивая внизу. Я настроил расположение вкладок, чтобы вкладки находились внизу экрана:

<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, все заработало.

1 Ответ

0 голосов
/ 24 декабря 2011

Я не могу понять вашу структуру макета, но я понял, что вы хотите показывать рекламу в верхней части экрана, и для этого я изменяю ваш код

 <?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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...