我有一個基本問題。在許多tabhost示例中,我們找到帶有圖像和文本的選項卡。如何在tabhost中居中文本?
在我的情況下,我只想顯示文本,但問題是我的文本是水平居中但不垂直(文本位於我的選項卡的底部)。
我試過了:android:layout_gravity =「center」在framelayout中,但它不起作用。
您有什麼想法嗎?
我的xml。
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
</FrameLayout>
</LinearLayout>
</TabHost>
解決:我定製了自己的標籤感謝以下教程:http://joshclemm.com/blog/?p=136
謝謝
它更好地使用自定義選項卡作爲默認選項卡具有圖標和文本的大小。 –
可能重複的[如何居中對齊Android中的標籤欄中的文本](http://stackoverflow.com/questions/5164443/how-to-center-align-text-in-a-tab-bar-in- android) – user7116
很久以前問過同樣的問題。請閱讀此問題[請在此輸入鏈接描述](http://stackoverflow.com/questions/5164443/how-to-center-align-text-in-a-tab-bar-in-android) – Dimon