首页 新闻 会员 周边

请教android的UI布局问题

0
悬赏园豆:100 [已解决问题] 解决于 2012-02-22 10:20

大家好,向大家请教android的UI布局问题,下面这两张图是一个android应用上截下来的:

 

 

请问图中的布局是怎么做的啊,下面的图标是一个图片铵钮吗?

请求高人指点,如能给出布局源码更是感激不尽。

观海云不远的主页 观海云不远 | 初学一级 | 园豆:89
提问于:2011-12-11 12:38
< >
分享
最佳答案
1

图中的布局就是tabhost的应用,只是把tabhost放到下面来了,样式做了调整,参考源码:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation
="vertical"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent">
<TabHost
android:id="@android:id/tabhost"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent"
android:paddingBottom
="55px">
<TextView
android:id="@+id/tx1"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent"
android:text
="this is Index tab"/>
<TextView
android:id="@+id/tx2"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent"
android:text
="this is Pick tab"/>
<TextView
android:id="@+id/tx3"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent"
android:text
="this is News tab"/>
<TextView
android:id="@+id/tx4"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent"
android:text
="this is Pick tab"/>
<TextView
android:id="@+id/tx5"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent"
android:text
="this is News tab"/>
</FrameLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height
="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_alignParentBottom
="true"
android:layout_width
="fill_parent"
android:layout_height
="55px"
android:tabStripEnabled
="false"/>
</RelativeLayout>
</TabHost>
</LinearLayout>

然后在Activity中调用下面的事件把tab的背景色设置成跟activity的背景色一样就可以了:

public static void setTabColor(TabHost tabhost) {
for(int i=0;i<tabhost.getTabWidget().getChildCount();i++){
tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#ff383737"));
}
tabhost.getCurrentTabView().setBackgroundColor(Color.parseColor("#AAAAAA"));
}
收获园豆:100
artwl | 专家六级 |园豆:16736 | 2011-12-12 09:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册