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);
}
Related
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>
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
I finished Android Action Bar Style Generator and downloaded the zip from there.
I copied and pasted all the folder in res, then changed the theme to let my app use the theme I edited. but The result is nothing changed!!!!
I am still beginner here. I am still not sure if there are other thing to deal with about changing Theme.
style_example.xml in folder values (created by the generator)
<style name="Theme.Example" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_example</item>
<item name="popupMenuStyle">#style/PopupMenu.Example</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Example</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Example</item>
<item name="actionDropDownStyle">#style/DropDownNav.Example</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Example</item>
<item name="actionModeBackground">#drawable/cab_background_top_example</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_example</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Example</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Example.Widget</item>
</style>
<style name="ActionBar.Solid.Example" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_example</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_example</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_example</item>
<item name="progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="ActionBar.Transparent.Example" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_example</item>
<item name="progressBarStyle">#style/ProgressBar.Example</item>
</style>
<style name="PopupMenu.Example" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
</style>
<style name="DropDownListView.Example" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_example</item>
</style>
<style name="DropDownNav.Example" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_example</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_example</item>
<item name="android:dropDownSelector">#drawable/selectable_background_example</item>
</style>
<style name="ProgressBar.Example" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_example</item>
</style>
<style name="ActionButton.CloseMode.Example" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_example</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Example.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Example</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Example</item>
</style>
AndroidManifest.xml (I just forgot to change the name so it is "Theme.Example")
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mes.learnupdater1" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Example" > --------------------- Theme applied
<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>
<activity
android:name=".Main2Activity"
android:label="#string/title_activity_main2" >
</activity>
</application>
</manifest>
If you want customized your them you need to edit theme under the value folder style. XML file
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>
I got a problem with action bar tab spacing.Below I am showing the screenshot of action bar tabs.
Below I am posted the codes relevant to this issue.
MainActivity.java:
ActionBar.Tab tab = actionBar.newTab()
.setText("Tab1")
.setTabListener(
new TabListener(this, Home.class.getName()));
View tabView = inflater.inflate(R.layout.fragment_home, null);
tabView.setBackgroundResource(R.drawable.gradient_shape); // set custom color
tab.setCustomView(tabView);
actionBar.addTab(tab);
drawable/gradient_shape.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="4dp" />
<stroke
android:width="1dp"
android:color="#0078a5" />
<gradient
android:angle="90"
android:endColor="#00adee"
android:startColor="#0078a5" />
<padding
android:bottom="25dp"
android:left="50dp"
android:right="50dp"
android:top="25dp" />
</shape>
styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>
values-v11/styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
</resources>
values-v14/styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>
Manifest:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar" >
<activity
android:name="com.smart.activity.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>
I need to remove the unwanted spacing between the tabs.The Tabs have to get merge one by one.And also the Action bar tab name wasn't displayed.Anybody can help me with this.Thank you.
Added this in values/styles.xml solved my problem:
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarTabStyle">#style/CustomTabWidget</item>
<item name="android:actionBarTabBarStyle">#style/MyActionBarTabBar</item>
</style>
<style name="CustomTabWidget" parent="#android:style/Widget.TabWidget">
<item name="android:textAppearance">#style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" parent="#android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">20sp</item>
<item name="android:textAppearance">#android:style/TextAppearance.Medium</item>
<item name="android:gravity">center</item>
<item name="android:paddingLeft">50dp</item>
<item name="android:paddingRight">20dp</item>
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="MyActionBarTabBar">
<item name="android:gravity">center</item>
</style>
</resources>
Then in Manifest:
I set a theme like this android:theme="#style/MyTheme" in application element.