我正在为各种屏幕尺寸设计我的应用,但我遇到了一个小问题。我无法更改标签内文字的大小。这就是我所做的。
首先,我创造了自己的风格。
<?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>
然后我将此样式用于相应的xml文件。
select storage_address,
storage_square,
cs.stuff_name as chiefSurname,
cs.stuff_surname as chiefName,
ws.stuff_name as workerSurname,
ws.stuff_surname as workerName
from storages
inner join storageRoster on storageRoster.storageRoster_id=storages.storage_roster_id
inner join Chiefs on storageRoster.chief_id = Chiefs.chief_id
inner join stuffs cs on Chiefs.chief_stuff_id = cs.stuff_id
inner join Workers on storageRoster.worker_id = Workers.chief_id
inner join ws cs on Workers.worker_stuff_id = ws.stuff_id
有什么想法吗?感谢
答案 0 :(得分:9)
我不知道你选择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>
这样您可以在标签中更改您想要的内容,例如
<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>
答案 1 :(得分:5)
使用tabTextAppearance更改选项卡内的文本大小。
app:tabTextAppearance="?android:attr/textAppearanceSmall"
我的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"/>
希望这会有所帮助。
答案 2 :(得分:0)
更改样式文件中的父级。
<style name="MineCustomTabText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse">
<item name="android:textSize">22sp</item>
</style>