0
我實現了tablayout,但它在模擬器中無法正常工作。設備中的高度顯示不正確。有人可以告訴我問題是什麼嗎?標籤高度在Android設備中無法正常使用
這是我的佈局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/black"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@android:id/tabs" />
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</TabHost>
</LinearLayout>
這是我的Java代碼設置的高度和寬度
for (int i =0; i<tabWidget.getChildCount(); i++) {
//tabWidget.getChildAt(i).setBackgroundColor(R.color.black);
tabWidget.getChildAt(i).getLayoutParams().height = height;
tabWidget.getChildAt(i).getLayoutParams().width = width;
RelativeLayout relLayout = (RelativeLayout)tabWidget.getChildAt(i);
TextView tv = (TextView)relLayout.getChildAt(1);
tv.setTextSize(10.0f);
tv.setTypeface(myTypeface1);
}
任何人能告訴我如何設置標籤欄的高度和寬度?給出的示例代碼
感謝
你爲什麼要設置從代碼中的寬度是多少? – Janusz 2011-01-27 15:36:09