0

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

RelativeLayout item = (RelativeLayout) findViewById(R.id.messagesactivityview); 
    View child = getLayoutInflater().inflate(R.layout.bottombartabs, null); 
    item.addView(child); 
    maketabs(); 

это код, я использую, чтобы надуть и здесь XML-файл с tabhost я пытаюсь надуть (обратите внимание thatI've установить layout_alignParentBottom истина, но она по-прежнему не работает)

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/tabhosty" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true" 
android:orientation="horizontal" > 

<ImageButton 
    android:id="@+id/switchtomessages" 
    android:layout_width="0dp" 
    android:layout_height="50dp" 
    android:layout_marginLeft="-3.5dip" 
    android:layout_marginRight="-3.5dip" 
    android:layout_weight="1" 
    android:background="@drawable/messages_icon" > 
</ImageButton> 

<ImageButton 
    android:id="@+id/switchtorequests" 
    android:layout_width="0dp" 
    android:layout_height="50dp" 
    android:layout_marginLeft="-3.5dip" 
    android:layout_marginRight="-3.5dip" 
    android:layout_weight="1" 
    android:background="@drawable/friend_request_icon" > 
</ImageButton> 

<ImageButton 
    android:id="@+id/switchtofriends" 
    android:layout_width="0dp" 
    android:layout_height="50dp" 
    android:layout_marginLeft="-3.5dip" 
    android:layout_marginRight="-3.5dip" 
    android:layout_weight="1" 
    android:background="@drawable/friends_icon" > 
</ImageButton> 

<ImageButton 
    android:id="@+id/uselesstab" 
    android:layout_width="0dp" 
    android:layout_height="50dp" 
    android:layout_marginLeft="-3.5dip" 
    android:layout_marginRight="-3.5dip" 
    android:layout_weight="1" 
    android:background="@drawable/settings_icon" > 
</ImageButton> 

</LinearLayout> 

, как я могу отправить его на дно изменения

+0

вы другой расположение. тот, в котором вы раздуваете этот макет, является ли это относительной компоновкой? –

+0

Попробуйте установить его в коде вместо xml, см. Здесь пример
http://stackoverflow.com/questions/4914590/how-to-set-the-android-property-layout-alignparentbottom-to-a-button- динамически – BenC

ответ

1

код для

RelativeLayout item = (RelativeLayout) findViewById(R.id.messagesactivityview); 
getLayoutInflater().inflate(R.layout.bottombartabs, item); 

без любой известный родитель, все LayoutParams, которые вы указали в корневом элементе вашего дерева XML, просто будут выброшены.

http://www.doubleencore.com/2013/05/layout-inflation-as-intended/

+1

Зачем им это? Пожалуйста, объясните, почему это действительно. – rayryeng

Смежные вопросы