어제 API19를 선택하여 맞춤형 ActionBar를 개발하고있었습니다. 문제의 원인으로 API21에 대한 지원 라이브러리와 프로젝트를 업데이트했습니다. 내 액션 바에는 메뉴 바가있는 버튼과 액션 바의 스타일이 필요하지 않습니다.Android 롤리팝으로 업데이트 한 후 ActionBar 스타일링
업데이트하기 전에 : 업데이트 후
는 :
다음
@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);
}
모든 오디오 솔루션을 MainActivity
에서 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에게 있습니다 이전의 최신 SDK를 사용하는 것처럼 액션 바를 복원 할 수 있습니까?
업데이트 : 내 Drawerfragment의 ActionBarDrawerToggle을 삭제하여 작업 표시 줄에서 화살표를 제거 할 수 있습니다.
액션 바는 지금 롤리팝에 감가 상각 도구 모음의 스타일과 버그가해야하지만
나는, 솔루션 및 작품을 테스트했다. 툴바 위젯을 사용하여 해결되었습니다. –어디에서 더 이상 사용되지 않는 정보를 얻었습니까 (그리고 버그가 있습니까 :)?) 툴바는 L에서 일하는 것이 선호되는 방법이지만, ActionBar는 더 이상 사용되지 않습니다. –
지원 라이브러리 v4에서 ActionBar가 사용되지 않으며 대신 v7을 사용하십시오. – Tapirboy