我遵循这个教程,并在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);
}提案没有显示completely..it在第一个选项卡上显示提议
我试图增加和缩小文本视图的文本大小.如何在选项卡中显示完整的文本?
发布于 2015-11-04 10:44:17
打开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"/>发布于 2019-02-15 17:45:18
我发现了两种方法
第一个是
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"/>https://stackoverflow.com/questions/33515963
复制相似问题