我試過的解決方案:如何在xml中設置tabwidget中tab的高度?
mTabHost.getTabWidget().getChildAt(i).setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,100));
,但我想這樣做的XML。
這是我的佈局:
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="10dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
style="@style/tab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:textColor="@drawable/tab_text_selector" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
我試圖設置TabWidget,但沒有結果的高度。
我使用自定義視圖爲單選項卡:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/img_tab"
android:layout_height="30dp"
android:layout_width="30dp"
android:scaleType="centerCrop"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
/>
<TextView
android:id="@+id/txv_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="22sp"
android:textAllCaps="true"
android:textIsSelectable="false"
android:layout_toRightOf="@+id/img_tab"
android:layout_margin="5dp">
</TextView>
<View android:id="@+id/tab_border"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_alignParentBottom="true"
android:background="@android:color/holo_green_light"
/>
</RelativeLayout>
我試圖設置RelativeLayout的高度,但每次我全屏高度的標籤的時間。
如何設置高度?
我標記這是答案,因爲在互聯網上搜索沒有辦法做我想做的事,但你的是我發現的唯一途徑。 – gdantimi 2013-05-27 14:24:34