ActionBarのTabBarのテキストサイズを変えたい

1,703 views
Skip to first unread message

sleee...@gmail.com

unread,
Dec 23, 2013, 3:29:46 PM12/23/13
to android-g...@googlegroups.com
はじめまして。大井と申します。
ActionBarのTabBarのテキストサイズを変えようとしたのですがうまくできません。
タブバーのテキストサイズ変更の方法を教えて下さいよろしくお願いいたします。

自分で実行したプログラムは
android studioでNew Projectから下記の設定(その他の設定は初期値)でプロジェクトを新規作成。
minimumSDK 2.1
Supports Mode fragments,Action Barにチェック
BrankActivity
ActionBarTabs(with ViewPager)

下記のファイルは新規作成時に自動生成されたもので編集していません
------------------AndroidManifest.xml------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
    package="com.example.app" >
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.app.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
----------------------------------------------------------------------------------

下記のファイルのみ編集しました。
------------------styles.xml------------------------------------------------
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarTabTextStyle">@style/MyActionBar</item>
    <item name="android:textSize">30dip</item><!--この行でメニューボタンの文字を大きくできることは確認しました-->
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.TabBar">
    <item name="android:textSize">30dip</item><!--この行でActionBarのTabBarのテキストサイズを変えようとしたのですが失敗しました。-->
</style>
</resources>
------------------------------------------------------------------------------------

HideCheck

unread,
Dec 24, 2013, 3:14:02 AM12/24/13
to android-g...@googlegroups.com
Compatは使ったこと無いのですが、以下のように変更してみてください
@style/Widget.AppCompat.ActionBar.TabBar

@style/Widget.AppCompat.ActionBar.TabText

ちなみに以下のようにするとできると思います。

<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarTabTextStyle">@style/TabTextStyle</item>
</style>


<style name="TabTextStyle" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:textSize">30dp</item>
</style>

2013年12月24日 5:29 sleee...@gmail.com <sleee...@gmail.com>:
> --
> このメールは Google グループのグループ「日本Androidの会」の登録者に送られています。
> このグループから退会し、メールの受信を停止するには、android-group-j...@googlegroups.com
> にメールを送信します。
> このグループに投稿するには、android-g...@googlegroups.com にメールを送信してください。
> http://groups.google.com/group/android-group-japan からこのグループにアクセスしてください。
> その他のオプションについては、https://groups.google.com/groups/opt_out にアクセスしてください。

sleee...@gmail.com

unread,
Dec 25, 2013, 11:23:21 PM12/25/13
to android-g...@googlegroups.com
返信有難うございました。
AppCompatを使う方を試して見たのですがテキストサイズに何も変化ありませんでした。
>@style/Widget.AppCompat.ActionBar.TabBar 
>↓ 
>@style/Widget.AppCompat.ActionBar.TabText 
変更箇所は、初回投稿時のstyles.xmlファイルで
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.TabBar">の行を
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.TabText">に変えて実行しましたが
実行できたもののタブのテキストサイズに変化は起こりませんでした。。


AppCompatを使わない方も試して見ましたがコンパイルは通るのですが実行時に
「問題が発生したためMyApplicationを終了します」というエラーが出てアプリケーションの起動ができませんでした。
下記はその時の実行方法です。
android studioでNew Projectから下記の設定(その他の設定は初期値)でプロジェクトを新規作成。
minimumSDK 4.1
BrankActivity
ActionBarTabs(with ViewPager)

下記のファイルのみ編集しました。
------------------styles.xml------------------------------------------------
<resources>
    <style name="AppBaseTheme" parent="android:Theme.Light"/><!--AppBaseThemeでエラーが出ていたので追加しました>
    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:actionBarTabTextStyle">@style/TabTextStyle</item>
    </style>
    <style name="TabTextStyle" parent="android:Theme.Holo.Light.DarkActionBar">
        <item name="android:textSize">30dp</item>
    </style>
</resources>
------------------------------------------------------------------------------------

sleee...@gmail.com

unread,
Dec 25, 2013, 11:34:28 PM12/25/13
to android-g...@googlegroups.com
AndroidOS2.1など古いバージョンでの対応を考えているので
引き続き、Android Support Libraryのsupport-v7-appcompatを使っての回答をご教示お願いします。
Reply all
Reply to author
Forward
0 new messages