I'm trying to edit the Title text size because it changes when in landscape screen. I found changing the dimension in SP can solve the problem. So I did this...
added a style in style.xml
<style name="Toolbar.TitleText"
parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">30sp</item>
</style>
and then in app_bar_main.xml under android.support.v7.widget.Toolbar i added this line
app:titleTextAppearance="@style/Toolbar.TitleText"
Now it gives the desired result on Main activity but all others activities are same. I have around 10 activities in my app. How can I change all the activities' Title? Please help. Thanks in advance.
my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/title_main"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".splash"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ch_1"
android:label="@string/ch_1" />
<activity
android:name=".ch_2"
android:label="@string/ch_2" />
<activity
android:name=".ch_3"
android:label="@string/ch_3" />
<activity
android:name=".ch_4"
android:label="@string/ch_4" />
<activity
android:name=".ch_5"
android:label="@string/ch_5" />
<activity
android:name=".ch_6"
android:label="@string/ch_6" />
<activity
android:name=".ch_7"
android:label="@string/ch_7" />
<activity
android:name=".ch_8"
android:label="@string/ch_8" />
<activity
android:name=".ch_9"
android:label="@string/ch_9" />
<activity
android:name=".ch_10"
android:label="@string/ch_10" />
<activity
android:name=".ch_11"
android:label="@string/ch_11" />
<activity android:name=".ch_12"
android:label="@string/ch_12" />
<activity
android:name=".ch_13"
android:label="@string/ch_13" />
<activity
android:name=".ch_14"
android:label="@string/ch_14" />
<activity
android:name=".ch_15"
android:label="@string/ch_15" />
<activity android:name=".view" />
</application>
my style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/white</item>
<item name="colorButtonNormal">@color/colorPrimary</item>
<item name="android:textAppearanceButton">@style/TextAppearance.AppCompat.Button.Custom</item>
</style>
<style name="Toolbar.TitleText"
parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">24sp</item>
</style>
<style name="TextAppearance.AppCompat.Button.Custom">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">28sp</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ActionButtonStyle" parent="@android:style/Widget.Holo.ActionButton">
<item name="android:minWidth">0dip</item>
<item name="android:paddingLeft">0dip</item>
<item name="android:paddingRight">0dip</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>
Ok, I have resolved the issue. The previous code was not working for other layouts because activity_main.xml was using toolbar instead of action bar, so i had to write another piece of style for the action bar. I added these style..
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">@style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textSize">24sp</item>
</style>
and then added the item in AppTheme like this..
<item name="actionBarStyle">@style/MyActionBar</item>
and it's working fine now. Thanks everyone for replying.