0

こんにちは私はアンドロイドプロジェクトに取り組んでいます。私は、タブウィジェットのストリップの色を変更し、タブのテキストのサイズも変更したいと思います。どうすればいいですか? enter image description hereアンドロイドスタジオでtabwidgetの色とタブのテキストサイズを変更するにはどうすればいいですか?

これはコードです:

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:background="@android:color/holo_blue_dark"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="wrap_content" 
      android:layout_height="50dp" 
      android:layout_marginLeft="30dp" 
      android:layout_marginTop="30dp" 
      android:elevation="0dp" 
      android:showDividers="none" 
      android:tabStripEnabled="false" /> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" /> 
    </LinearLayout> 
</TabHost> 
+0

あなたは、これは[http://stackoverflow.com/a/15750561/4049612](http://stackoverflow.com/a/15750561/4049612)タブ下の色を変更するためにチェックすることができますが、 – Krishna

答えて

0

テキストサイズ

そのきれいではありませんを変更するが、この汚い修正しようとする:

TabWidget tw = (TabWidget)tabHost.findViewById(android.R.id.tabs); 
View tabView = tw.getChildTabViewAt(0); 
TextView tv = (TextView)tabView.findViewById(android.R.id.title); 
tv.setTextSize(20); 

または

//Do this to hack font size of title text 
LinearLayout ll = (LinearLayout) tabHost.getChildAt(0); 
TabWidget tw = (TabWidget) ll.getChildAt(0); 

// for changing the text size of first tab 
RelativeLayout rllf = (RelativeLayout) tw.getChildAt(0); 
TextView lf = (TextView) rllf.getChildAt(1); 
lf.setTextSize(21); 
lf.setPadding(0, 0, 0, 6); 

または

final TabWidget tw = (TabWidget)mTabHost.findViewById(android.R.id.tabs); 
for (int i = 0; i < tw.getChildCount(); ++i) 
{ 
    final View tabView = tw.getChildTabViewAt(i); 
    final TextView tv = (TextView)tabView.findViewById(android.R.id.title); 
    tv.setTextSize(20); 
} 
+0

私のコードではテキストビューはありませんので、どのようにjavaファイルでtextviewを取得するのですか? –

関連する問題