我正在学习本教程,并在CustomViewIconTextTabsActivity
:中更改了setupTabIcons
的代码
private void setupTabIcons() {
TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tabOne.setText("PROPOSAL");
tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_tab_favourite, 0, 0);
tabLayout.getTabAt(0).setCustomView(tabOne);
TextView tabTwo = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tabTwo.setText("MY JOBS");
tabTwo.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_tab_call, 0, 0);
tabLayout.getTabAt(1).setCustomView(tabTwo);
TextView tabThree = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tabThree.setText("MESSAGE");
tabThree.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_tab_contacts, 0, 0);
tabLayout.getTabAt(2).setCustomView(tabThree);
TextView tabFour = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tabFour.setText("PROFILE");
tabFour.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_tab_contacts, 0, 0);
tabLayout.getTabAt(3).setCustomView(tabFour);
}
建议书未完全显示。。在的第一个选项卡上显示PROOSA
我试图增加和减少文本视图的文本大小。。。如何在选项卡中显示完整的文本?
打开activity_custom_view_icon_text_tabs.xml并将TabLayout
的tabMode
更改为scrollable
:
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tab_layout_height"
app:tabMode="scrollable"
app:tabGravity="fill"/>
我发现有两种方法
第一个是
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
像一样使用这个主题
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabGravity="fill"/>
第二:使用app:tabMode="scrollable"
类似:
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabGravity="fill"/>