【发布时间】:2014-08-10 00:04:10
【问题描述】:
我正在尝试将 tabhost 动态膨胀到视图的底部;但是,无论我做什么,它都会被发送到顶部。
RelativeLayout item = (RelativeLayout) findViewById(R.id.messagesactivityview);
View child = getLayoutInflater().inflate(R.layout.bottombartabs, null);
item.addView(child);
maketabs();
这是我用来膨胀的代码,这是我要膨胀的 tabhost 的 xml 文件(请注意,我已将 layout_alignParentBottom 设置为 true,但它仍然不起作用)
<?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>
如何发送到底部
【问题讨论】:
-
你的其他布局。您在其中膨胀此布局的那个,是相对布局吗?
-
尝试在代码而不是 xml 中设置它,请参见此处的示例
stackoverflow.com/questions/4914590/…
标签: android android-linearlayout android-inflate android-relativelayout