How to change setting icon in Navigation Drawer Layout? - android

I don't know how to change the one which is red circle.
I think just change the icon like this
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:title="#string/action_settings"
android:icon="#drawable/icon_logout"
app:showAsAction="never" />
</menu>
but.. It isn't... so How can I change about it?
and It is my onCreate..
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.activity_base);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar((Toolbar) toolbar);
mContext = this;
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener((DrawerLayout.DrawerListener) toggle);
toggle.syncState();
setTitle("For Good Posture");
setNaviMenu();
displaySelectedScreen(R.id.nav_home);
setDisplaySize();
}
updated
This is my style.xml
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#fff</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="#style/Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/black</item>
</style>
<style name="ToolBarStyle" parent="">
<item name="android:elevation">#dimen/toolbar_elevation</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">#style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<dimen name="toolbar_elevation">4dp</dimen>
<style name="RadioButtonStyle" parent="#android:style/Widget.CompoundButton">
<item name="android:background">#drawable/radiobutton_selector</item>
<item name="android:button">#null</item>
</style>
<style name="DialogNoTitleBar" parent="android:style/Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="TabLayoutTextStyle">
<item name="android:textSize">16sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="ButtonSubmit">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:background">#drawable/style_btn_login</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:textSize">17dp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#color/white</item>
</style>
<style name="MyTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionOverflowButtonStyle">#style/ActionButtonOverflowStyle</item>
</style>
<style name="ActionButtonOverflowStyle" parent="android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/icon_logout</item>
</style>
</resources>
updated
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.cheon.android.forgoodposture_180102"
android:versionCode="6"
android:versionName="1.6">
<uses-sdk
android:minSdkVersion="26"
android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#mipmap/app_icon_full"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".Login.IntroActivity"
android:theme="#style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AppInformation.AppInfoActivity" />
<activity android:name=".Signup.SignupActivity" />
<activity
android:name=".SearchPassowrd.SearchPasswordActivity"
android:theme="#style/MyMaterialTheme" />
<activity
android:name=".Login.LoginActivity"
android:theme="#style/MyMaterialTheme" />
<activity android:name=".Signup.BeforeConfirmActivity" />
<activity
android:name=".Main.BaseActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="#string/title_activity_base"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustPan|adjustNothing" />
<activity
android:name=".WorkoutDiary.SatisfactionActivity"
android:theme="#style/DialogNoTitleBar" />
<activity
android:name=".WorkoutDiary.ImplementActivity"
android:theme="#style/DialogNoTitleBar" />
<receiver android:name=".WorkoutDiary.AlarmReceiver" />
</application>
</manifest>

The problem you are having is because it is not SETTINGS button, but an overflow button. That's why setting icon doesn't work.
To change this three dots, you should specify correct android:actionOverflowButtonStyle style for your activity THEME like this:
<style name="MyTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionOverflowButtonStyle">#style/ActionButtonOverflowStyle</item>
</style>
<style name="ActionButtonOverflowStyle" parent="android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/YOUR_DRAWABLE_IMAGE</item>
</style>
The result I have now is :

You can use custom menu item view, also see below link.
https://stablekernel.com/using-custom-views-as-menu-items/
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/activity_main_alerts_menu_item"
android:title="Alerts"
app:actionLayout="#layout/view_alertsbadge" <!-- important part -->
app:showAsAction="ifRoom"/>
<item
android:id="#+id/activity_main_update_menu_item"
android:icon="#drawable/ic_refresh_white_24dp"
android:title="Update"
app:showAsAction="ifRoom"/>
</menu>

Related

android You cannot combine custom titles with other title features

I am using Android Studio 3.2 and Android API 23 develop the app, when I try to set a custom title bar it display the error You cannot combine custom titles with other title features.
I google the the error and try some answers on so, but it can't solve the problem, I am stucked.
the code is as following,
the manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shashiwang.shashiapp">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity" android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
the styles:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="windowNoTitle">true</item>
<!--<item name="windowActionBar">false</item>-->
</style>
<style name="TitleBarLayout" >
<item name="android:background">#color/colorTitleBarBg</item>
<item name="android:layout_height">#dimen/title_bar_height</item>
<item name="android:layout_width">match_parent</item>
</style>
<style name="TitleBarTitle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:color">#color/colorTitleBarTitle</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:text">#string/app_name</item>
<item name="android:textSize">#dimen/title_bar_title_font_size</item>
<item name="android:textStyle">bold</item>
</style>
<style name="TitleBarContactLayout">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:orientation">vertical</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:gravity">center</item>
<item name="android:layout_marginRight">10dp</item>
</style>
<style name="TitleBarContactIcon">
<item name="android:layout_width">#dimen/title_bar_contact_icon_width</item>
<item name="android:layout_height">#dimen/title_bar_contact_icon_height</item>
<item name="android:src">#drawable/ic_contact</item>
</style>
<style name="TitleBarContactText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:text">#string/title_bar_contact_text</item>
<item name="android:textSize">#dimen/title_bar_contact_font_size</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
the layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/titleBarContainer"
style="#style/TitleBarLayout">
<TextView
android:id="#+id/TitleBarTitle"
style="#style/TitleBarTitle" />
<LinearLayout
android:id="#+id/TitleBarContactContainer"
style="#style/TitleBarContactLayout">
<ImageView
android:id="#+id/titleBarContactIcon"
style="#style/TitleBarContactIcon" />
<TextView
android:id="#+id/TitleBarContactText"
style="#style/TitleBarContactText" />
</LinearLayout>
</RelativeLayout>
the activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar_layout);
}

Android window fullscreen with no action bar

I've made my app fullscreen with no title by writing following code
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
But I can open action bar and notifications bar as we usually do from top.
Is there any way to never show top action bar.
Fullscreen App:
Visible status bar:
As soon as I touch and slide down from top mobile status bar becomes visible. How to stop that ?
Updates:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sampleapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:stateNotNeeded="true"
android:theme="#style/AppTheme.Wallpaper">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".LockScreenActivity" />
</application>
</manifest>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<!-- THIS IS THE MAIN THEME -->
<style name="AppTheme.Wallpaper" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
Use this code inside the style.xml
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
</style>
First, make these changes in the themes.xml file as shown below and then, in AndroidManifest.xml file add "android:theme="#style/FullScreen" this line in activity section.
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme._your_app_name" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">#color/purple_500</item>
<item name="colorPrimaryVariant">#color/purple_700</item>
<item name="colorOnPrimary">#color/white</item>
<item name="colorSecondary">#color/teal_200</item>
<item name="colorSecondaryVariant">#color/teal_700</item>
<item name="colorOnSecondary">#color/black</item>
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
</style>
<style name="FullScreen" parent="Theme._your_app_name">
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
Don't forget to add "android:theme="#style/FullScreen" line in AndroidManifest.xml file under activity section.
Try this!
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
in style.xml:
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
</style>
in manifest application tag:
android:theme="#style/AppTheme"

How to create trasparent activity when i click Floating action button

First sorry for my bad English ,I am creating activity within that activity , i create floating action button ,when i click Floating Action Button on click action i show one activity it working fine but how to change my activity to transparent activity with no action bar
i change manifest file but getting some errors
mainifest file
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_fullscreen"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.aa.bunny.aabunny.Main2Activity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name=".ScrollingActivity"
android:label="#string/title_activity_scrolling"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
<activity android:name=".Main22Activity" >
</activity>
</application>
Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
<style name="Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
Change activity theme to achieve transparency.
create a style like this
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
and use this in manifest
<activity android:name=".TransparentActivity" android:theme="#style/Theme.Transparent">
Happy coding...
You can apply theme like..
android:theme="#android:style/Theme.Translucent"
Or else you can also create your own theme in style..
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
You can also Set background of the activity as a transparent png image or a transparent color code

ActionBar color not changing

I'm trying to change the color of the ActionBar in my app. The color was changed in the preview tap when opening the layout file, but not when I run it on my device (5.0.1). I need the status bar to be also colored.
Here is my styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="Test" parent="android:Theme.Material.Light">
<item name="android:actionBarStyle">#style/TestActionBar</item>
</style>
<style name="TestActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#color/primary_dark</item>
<item name="android:statusBarColor">#color/primary_dark</item>
<!--<item name="android:colorPrimary">#color/primary_dark</item>-->
<!--<item name="android:actionMenuTextColor">#FFFFFF</item>-->
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/primary_darker</item>
</style>
<style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:windowBackground">#color/primary</item>
<item name="colorControlNormal">#color/iron</item>
<item name="colorControlActivated">#color/white</item>
<item name="colorControlHighlight">#color/white</item>
<item name="android:textColorHint">#color/iron</item>
<item name="colorButtonNormal">#color/primary_darker</item>
<item name="android:colorButtonNormal">#color/primary_darker</item>
</style>
<style name="AppTheme.Dark.Dialog" parent="Theme.AppCompat.Dialog">
<item name="colorAccent">#color/white</item>
<item name="android:textColorPrimary">#color/iron</item>
<item name="android:background">#color/primary</item>
</style>
</resources>
My manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.motassem.beacontest" >
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Material.Light.DarkActionBar" >
<activity
android:name=".TestActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".LoginActivity"
android:theme="#style/AppTheme.Dark" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SignupActivity"
android:theme="#style/AppTheme.Dark" >
</activity>
<activity
android:name=".HomeActivity"
android:label="#string/title_activity_home" >
</activity>
</application>
</manifest>
My layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:name="com.example.motassem.beacontest.HomeActivityFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".HomeActivity">
<fragment android:name="com.example.motassem.beacontest.HomeActivityFragment"
android:id="#+id/frag_total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="#layout/fragment_home" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#android:color/black" />
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal" />
</LinearLayout>
And my fragment.xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/string_total_saved"
android:id="#+id/tvTotal"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:textSize="40sp"
android:id="#+id/textView2"
android:layout_below="#+id/tvTotal"
android:layout_centerHorizontal="true" />
Edit
After adding AppTheme in the solution's style.xml, the action bar is missing.
In your Activity (which has to extend an AppCompatActivity) or in your Application you should use a AppCompat Theme.
If you are not using a Toolbar in your layout use somenthing like:
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
</style>
Otherwise, if you are using a Toolbar use:
<style name="AppTheme.NoActionBar" >
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
I added the following to style.xml and applied it for my activity
<style name="Accelerator" parent="#style/Theme.AppCompat">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/primary_dark</item>
<item name="colorControlHighlight">#color/primary_darker</item>
<item name="colorControlActivated">#color/white</item>
<item name="android:navigationBarColor">#color/primary</item>
<item name="android:statusBarColor">#color/primary_dark</item>
<item name="android:textColorPrimary">#color/accent</item>
</style>

Action bar style theme generator theme not getting applied

So I used the action bar style generator to create a theme with style compatibility mode set to AppCompat. I downloaded the ZIP file and copy and pasted all the files inside my folder but the theme isn't showing up when emulator is ran.
The styles_actionstyle.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Actionstyle" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_actionstyle</item >
<item name="popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Actionstyle</item>
<item name="actionDropDownStyle">#style/DropDownNav.Actionstyle</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Actionstyle</item>
<item name="actionModeBackground">#drawable/cab_background_top_actionstyle</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_actionstyle</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Actionstyle</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Actionstyle.Widget</item>
</style>
<style name="ActionBar.Solid.Actionstyle" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_actionstyle</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_actionstyle</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_actionstyle</item>
<item name="progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<style name="ActionBar.Transparent.Actionstyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_actionstyle</item>
<item name="progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<style name="PopupMenu.Actionstyle" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_actionstyle</item>
</style>
<style name="DropDownListView.Actionstyle" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_actionstyle</item>
</style>
<style name="ActionBarTabStyle.Actionstyle" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_actionstyle</item>
</style>
<style name="DropDownNav.Actionstyle" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_actionstyle</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_actionstyle</item>
<item name="android:dropDownSelector">#drawable/selectable_background_actionstyle</item>
</style>
<style name="ProgressBar.Actionstyle" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_actionstyle</item>
</style>
<style name="ActionButton.CloseMode.Actionstyle" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_actionstyle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Actionstyle.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
</style>
</resources>
The V14 version:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Actionstyle" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_actionstyle</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Actionstyle</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Actionstyle</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Actionstyle</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_actionstyle</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_actionstyle</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Actionstyle</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Actionstyle.Widget</item>
</style>
<style name="ActionBar.Solid.Actionstyle" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/ab_background_textured_actionstyle</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_actionstyle</item>
<item name="android:backgroundSplit">#drawable/ab_background_textured_actionstyle</item>
<item name="android:progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<style name="ActionBar.Transparent.Actionstyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/ab_transparent_actionstyle</item>
<item name="android:progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Actionstyle.Widget" parent="#style/Theme.AppCompat">
<item name="android:popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
</style>
</resources>
The manifests file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.blooddonation2" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Actionstyle" >
<activity
android:name=".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>

Categories

Resources