1

これが以前に尋ねられた場合、担当者を危険にさらすつもりですが、Android(または自分自身)に本当に不満を感じています。ActionBar のタイトル テキストの色を白から赤に変更し、テキストの横にロゴを挿入しようとしていますが、何も変更されていないようです。

タイトルテキスト

SOを検索して検索し、次のような多くのソリューションを試しました:

Android 4.3 API 18でActionBarのタイトルテキストの色を変更する方法

XML経由でAndroidアクションバーのタイトルテキストの色を変更する

しかし、私には何もうまくいきません。誰かが私の理解不足を指摘してくれることを願っています。

ここに私のマニフェストスニペットがあります:

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/small_bc_logo"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".BckmMainActivity"
        android:label="@string/app_name" >

私の styles.xml (res/values-14) は、最初に見たリンクから基本的にコピーしたものです。

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    <!-- API 14 theme customizations can go here. -->
    <item name="android:textColor">@color/black</item>
    <item name="android:icon">@drawable/small_bc_logo</item>
</style>

<style name="ActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="android:titleTextStyle">@style/TitleBarTextColor</item>
</style>

<style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/red</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

私のcolors.xml:

<resources>
  <color name="red">#A52421</color>
  <color name="black">#000000</color>
</resources>

私のstrings.xml:

<resources>

  <string name="app_name">BCKM</string>
  <string name="action_settings">Settings</string>

</resources>

そして、さらに情報を追加するために、私の Main Activity クラス:

public class BckmMainActivity extends ActionBarActivity {

private final Handler handler = new Handler();

private PagerSlidingTabStrip tabs;
private ViewPager pager;
private MyPagerAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bckm_main);

    tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    pager = (ViewPager) findViewById(R.id.pager);
    adapter = new MyPagerAdapter(getSupportFragmentManager());

    pager.setAdapter(adapter);

    final int pageMargin = (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 4, getResources()
                    .getDisplayMetrics());
    pager.setPageMargin(pageMargin);

    tabs.setViewPager(pager);
}

...
...
...

どうもありがとう。

4

2 に答える 2

1

これにより、テキストの色が変更されます。

ActionBar ab = getActionBar();
ab.setTitle(Html.fromHtml("<font color='#ff0000'>YourTitleHere </font>"));
于 2014-12-21T09:08:16.367 に答える