/ / Android TabSpec text padding - android, tabs, polstrovanie

Textové padding pre Android TabSpec - android, tabs, padding

Potrebujem pridať nejaké polstrovanie na prvok tabWidget. Snažím sa pridať políčko na text pod obrázkom.

Snažím sa s týmto:

    for (int i = 0; i < tabHost.getChildCount(); i++) {
tabHost.getChildAt(i).setPadding(2, 2, 2, 2);

}

Ale zdá sa, že sa nič nestane.

Tu je xml:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>

</TabHost>

odpovede:

0 pre odpoveď č. 1

Odpoveď z podobnej otázky bola nájdená tu.

final TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
tv.setPadding(2, 2, 2, 2);