-1

здесь цвет текста по умолчанию в строке действия идет черный. Мне нужен цвет текста как белый. Как изменить цвет по умолчанию на черный цвет до белого моего названия в actiobar.Как изменить цвет текста в панели действий, bydefault наступает черный?

<!-- 
    Base application theme, dependent on API level. This theme is replaced 
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 



--> 
<style name="AppBaseTheme" parent="android:Theme.Light"> 
    <!-- 
     Theme customizations available in newer API levels can go in 
     res/values-vXX/styles.xml, while customizations related to 
     backward-compatibility can go here. 



    --> 
</style> 

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

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> 
    <item name="android:background">@color/MyColor</item> 
    <item name="background">@color/MyColor</item> 
</style> 

<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light"> 
    <item name="android:actionBarStyle">@style/MyActionBar</item> 
    <item name="actionBarStyle">@style/MyActionBar</item> 
</style> 

+0

размещено style.xml? –

+0

@ ρяσѕρєя K да. –

ответ

0

Вы можете установить пользовательские ActionBar так:

custom_action_bar.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:background="#526e83" 
    android:descendantFocusability="blocksDescendants"> 

    <ImageView 
     android:id="@+id/ContactImageId" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/logo" 
     android:paddingLeft="100dp" 
     /> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:paddingTop="10dp"> 

     <TextView 
      android:id="@+id/CTS" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="15dp" 
      android:textColor="#ffffff" 
      android:text="CTS" 
      android:textStyle="bold"/> 

     <TextView 
      android:id="@+id/UserName" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="10dp" 
      android:textColor="#ffffff" 
      android:text="Welcome: HKH"/> 
    </LinearLayout> 
</LinearLayout> 

и в каждой деятельности вы можете ча Л.Л. этот метод в OnCreate для установки ActionBar к пользовательскому ActionBar:

public void addTextToActionBar() { 

     android.support.v7.app.ActionBar actionBar = getSupportActionBar(); 
     actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME); 
     actionBar.setIcon(android.R.color.transparent); 
     actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#526e83"))); 
     View cView = getLayoutInflater().inflate(R.layout.custom_action_bar, null); 
     actionBar.setCustomView(cView); 
    } 

и при разрешении -> значения -> изменение стилей это:

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
    </style> 

</resources> 

я надеюсь, что это поможет

+0

+0

это Ждут» t работать, как я написал @PritiRathod ?? –

Смежные вопросы