6

Я разрабатывал пользовательский ActionBar, выбирая вчера API19, я обновил библиотеки поддержки и проект API21, что вызвало у меня проблемы. В моей панели действий есть кнопка «Меню-стрелка», которая мне не нужна, и стиль изменений в панели действий.ActionBar styling после обновления на Android lollipop

Перед обновление: enter image description here

После обновления: enter image description here

Ниже приводится style.xml

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

    </style> 
    <!-- Base application theme. --> 
    <style name="AppTheme" parent="AppBaseTheme"> 
     <item name="android:buttonStyle">@style/ButtonAppTheme</item> 

     <item name="actionBarItemBackground">@drawable/selectable_background_apptheme</item> 
     <item name="popupMenuStyle">@style/PopupMenu.Apptheme</item> 
     <item name="dropDownListViewStyle">@style/DropDownListView.Apptheme</item> 
     <item name="actionBarTabStyle">@style/ActionBarTabStyle.Apptheme</item> 
     <item name="actionDropDownStyle">@style/DropDownNav.Apptheme</item> 
     <item name="actionBarStyle">@style/ActionBar.Solid.Apptheme</item> 
     <item name="actionModeBackground">@drawable/cab_background_top_apptheme</item> 
     <item name="actionModeSplitBackground">@drawable/cab_background_bottom_apptheme</item> 
     <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Apptheme</item> 

     <!-- Light.DarkActionBar specific --> 
     <item name="actionBarWidgetTheme">@style/Theme.Apptheme.Widget</item> 

    </style> 

    <!-- Base application theme for Full screen Activities --> 
    <style name="AppThemeFullScreen" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen"> 
     <item name="android:buttonStyle">@style/ButtonAppTheme</item> 
    </style> 

    <!-- Button Style --> 
    <style name="ButtonAppTheme" parent="android:Widget.Button"> 
     <item name="android:background">@drawable/btn_background</item> 
     <item name="android:minHeight">48dip</item> 
     <item name="android:minWidth">64dip</item> 
     <item name="android:textColor">@color/btn_text_color_default</item> 

    </style> 


    <style name="ActionBar.Solid.Apptheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> 
     <item name="background">@drawable/ab_solid_apptheme</item> 
     <item name="backgroundStacked">@drawable/ab_stacked_solid_apptheme</item> 
     <item name="backgroundSplit">@drawable/ab_bottom_solid_apptheme</item> 
     <item name="progressBarStyle">@style/ProgressBar.Apptheme</item> 
    </style> 

    <style name="ActionBar.Transparent.Apptheme" parent="@style/Widget.AppCompat.ActionBar"> 
     <item name="background">@drawable/ab_transparent_apptheme</item> 
     <item name="progressBarStyle">@style/ProgressBar.Apptheme</item> 
    </style> 

    <style name="PopupMenu.Apptheme" parent="@style/Widget.AppCompat.PopupMenu"> 
     <item name="android:popupBackground">@drawable/menu_dropdown_panel_apptheme</item> 
    </style> 

    <style name="DropDownListView.Apptheme" parent="@style/Widget.AppCompat.ListView.DropDown"> 
     <item name="android:listSelector">@drawable/selectable_background_apptheme</item> 
    </style> 

    <style name="ActionBarTabStyle.Apptheme" parent="@style/Widget.AppCompat.ActionBar.TabView"> 
     <item name="android:background">@drawable/tab_indicator_ab_apptheme</item> 
    </style> 

    <style name="DropDownNav.Apptheme" parent="@style/Widget.AppCompat.Spinner.DropDown.ActionBar"> 
     <item name="android:background">@drawable/spinner_background_ab_apptheme</item> 
     <item name="android:popupBackground">@drawable/menu_dropdown_panel_apptheme</item> 
     <item name="android:dropDownSelector">@drawable/selectable_background_apptheme</item> 
    </style> 

    <style name="ProgressBar.Apptheme" parent="@style/Widget.AppCompat.ProgressBar.Horizontal"> 
     <item name="android:progressDrawable">@drawable/progress_horizontal_apptheme</item> 
    </style> 

    <style name="ActionButton.CloseMode.Apptheme" parent="@style/Widget.AppCompat.ActionButton.CloseMode"> 
     <item name="android:background">@drawable/btn_cab_done_apptheme</item> 
    </style> 

    <!-- this style is only referenced in a Light.DarkActionBar based theme --> 
    <style name="Theme.Apptheme.Widget" parent="@style/Theme.AppCompat"> 
     <item name="popupMenuStyle">@style/PopupMenu.Apptheme</item> 
     <item name="dropDownListViewStyle">@style/DropDownListView.Apptheme</item> 
    </style> 

</resources> 

OnCreate из MainActivity

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

    mNavigationDrawerFragment = (NavigationDrawerFragment) 
     getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); 
    // mTitle = getTitle(); 

    // Set up the drawer. 
    mNavigationDrawerFragment.setUp(
     R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); 

    actionBar = getSupportActionBar(); 
    // Toolbar toolbar =(Toolbar) findViewById(R.id.toolbar); 
    // setSupportActionBar(toolbar); 

    LayoutInflater mInflater = LayoutInflater.from(this); 

    LayoutParams layout = new LayoutParams(
     LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 
    View mCustomView = mInflater.inflate(R.layout.actionbar, null); 
    actionBar.setCustomView(mCustomView,layout); 
    actionBar.setDisplayShowCustomEnabled(true); 
    actionBar.setDisplayShowHomeEnabled(false); 
    actionBar.setDisplayShowTitleEnabled(false); 
    actionBar.setDefaultDisplayHomeAsUpEnabled(false); 
    actionBar.setDisplayUseLogoEnabled(false); 
} 

Любой Solut ion, чтобы восстановить панель действий, как ранее, используя последний SDK?

Обновление: Я удаляю стрелку из панели действий, удаляя ActionBarDrawerToggle со всех сторон в моем Drawerfragment.

enter image description here

Теперь я столкнулся только стилизации вопрос ActionBar. Прокладка слева и цвет фона Actionabr

+0

ActionBar теперь амортизируется в леденец и есть ошибки. Решается с помощью виджета панели инструментов. –

+0

Где вы получили информацию, она устарела (и есть ошибки :))? Панель инструментов - предпочтительный способ делать вещи в L, но ActionBar определенно не устарел. –

+0

ActionBar в библиотеке поддержки v4 устарел, вместо этого используйте v7. – Tapirboy

ответ

5

Если вам нужен только цвет, вы должны определить его как primaryColor в своей теме. Похоже, что много вещей, которые вы получили, просто наложили оттенок на ActionBar.

<style name="Theme.MyTheme" parent="Theme.AppCompat"> 
    <item name="colorPrimary">@color/primary</item> 
</style> 

<color name="primary">#ff5722</color> 

Стрелкой вы имеете в виду это getSupportActionBar().setDisplayHomeAsUpEnabled(true|false); и вам больше не нужно (не нужно) использовать свой собственный значок ящик, как он входит в AppCompat v7. (mDrawerToggle.setDrawerIndicatorEnabled(true);)

+0

Это не проблема цвета. это дополнение. –

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