The*_*heo 4 tabs android text-size
我正在设计我的应用程序的各种屏幕尺寸,但我有一个小问题.我无法更改选项卡中文本的大小.这就是我做的.
首先,我创造了自己的风格.
<style name="MineCustomTabText" parent="TextAppearance.Design.Tab">
<item name="android:textSize">22sp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后我将此样式用于相应的xml文件.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="manutd.football.app.interviews.InterviewsActivity">
<manutd.football.app.SlidingTabLayout
android:id="@+id/tabs"
app:tabTextAppearance="@style/MineCustomTabText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="2dp"
android:background="#656e99" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_below="@+id/tabs"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1"
></android.support.v4.view.ViewPager>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢
好吧,我知道你选择的原因 manutd.football.app.SlidingTabLayout
您可以使用
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>
Run Code Online (Sandbox Code Playgroud)
通过这个,您可以在标签中更改您想要的内容
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
<item name="tabMaxWidth">@dimen/tab_max_width</item>
<item name="tabIndicatorColor">?attr/colorAccent</item>
<item name="tabIndicatorHeight">2dp</item>
<item name="tabPaddingStart">12dp</item>
<item name="tabPaddingEnd">12dp</item>
<item name="tabBackground">?attr/selectableItemBackground</item>
<item name="tabTextAppearance">@style/MyCustomTabTextAppearance</item>
<item name="tabSelectedTextColor">?android:textColorPrimary</item>
</style>
<style name="MyCustomTabTextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textSize">14sp</item>
<item name="android:textColor">?android:textColorSecondary</item>
<item name="textAllCaps">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
使用tabTextAppearance更改选项卡内文本的大小.
app:tabTextAppearance="?android:attr/textAppearanceSmall"
Run Code Online (Sandbox Code Playgroud)
我的TabLayout的完整代码是
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tabLayoutBGColor"
app:tabSelectedTextColor="@color/colorAccent"
app:tabTextAppearance="?android:attr/textAppearanceSmall"
app:tabMode="fixed"
app:tabGravity="fill"/>
Run Code Online (Sandbox Code Playgroud)
希望这会有所帮助.
| 归档时间: |
|
| 查看次数: |
7633 次 |
| 最近记录: |