Hey i want to change my statusbar color i set in my styles.xml and v21/styles.xml this:
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/colorPrimaryText</item>
<item name="android:windowBackground">#color/windowBackground</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowActionBarOverlay">false</item>
</style>
and in my main activity this:
Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(myToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setElevation(0);
getSupportActionBar().getThemedContext();
Window window = this.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// finally change the color
window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
but it dosent work... can someone help? I use AppCompact in my mainAcitvity
Call this method to change color from Kitkat bellow Kitkat works normally
//Utils.java
public static boolean hasKitKat()
{
return Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT;
}
//Your Activity
public void applyKitKatTranslucency(int color) {
if (Utils.hasKitKat()) {
if (mTintManager == null)
mTintManager = new SystemBarTintManager(this);
mTintManager.setStatusBarTintEnabled(true);
mTintManager.setStatusBarTintColor(color);
}
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
}
Try the below.
window.setStatusBarColor(this.getResources().getColor(R.color.statusbar));
First create a new color within your color resource file. You need to define the colour inside your colour.xml resource file.
<item name="statusbar" type="color">#FFF</item>
I hope this helps..
Related
I'm trying to change the size of my overflow menu button. I've changed the actual icon from the default 3 dots to my own settings icon in my drawables. Here's the code:
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>
<item name="android:colorForeground">#color/colorPrimaryDark</item>
<item name="android:actionOverflowButtonStyle">#style/ToolbarOptions</item>
</style>
<!--Toolbar-->
<style name="ToolbarOptions" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:src">#drawable/settings</item>
<item name="android:contentDescription">settings</item>
<item name="android:width">9dp</item>
<item name="android:height">9dp</item>
</style>
</resources>
and then here's the java:
public class Home extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home_menu, menu);
return true;
}
}
So how do I change the size of the settings icon? I've changed the width and height in the style tags below but it stays the same.
I created an app and It has multiple themes and it changes dynamically. I mean in run-time user can choose different themes. so that UI components color changes in runtime. I got stuck in a strange problem. Problem is status bar color is not changing according to theme. statusBar always stays in initial theme color.
values-v21/style.xml is as below
<style name="AppTheme" 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:textColorPrimary">#color/primary_text</item>
<item name="android:icon">#color/icons</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
values-v21/themes.xml is as below
===================================
<resources>
<style name="AppThemeRed" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#F44336</item>
<item name="colorPrimaryDark">#D32F2F</item>
<item name="colorAccent">#FFCDD2</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:icon">#color/icons</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppThemeAmber" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#FFC107</item>
<item name="colorPrimaryDark">#FFA000</item>
<item name="colorAccent">#FFEB3B</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:icon">#color/icons</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppThemeBlue" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#3F51B5</item>
<item name="colorPrimaryDark">#303F9F</item>
<item name="colorAccent">#448AFF</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppThemePurple" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#9C27B0</item>
<item name="colorPrimaryDark">#7B1FA2</item>
<item name="colorAccent">#7C4DFF</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppThemeYellow" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#FFEB3B</item>
<item name="colorPrimaryDark">#FBC02D</item>
<item name="colorAccent">#CDDC39</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
</resources>
when user selects a theme from theme selection dialog i calling a function and setting theme for that activity, also recreating activity.
public static void onActivityCreateSetTheme(Activity activity)
{
switch (sTheme)
{
case 0:
activity.setTheme(R.style.AppThemeRed);
break;
case 1:
activity.setTheme(R.style.AppThemeAmber);
break;
default:
case 2:
activity.setTheme(R.style.AppTheme);
break;
case 3:
activity.setTheme(R.style.AppThemeBlue);
break;
case 4:
activity.setTheme(R.style.AppThemePurple);
break;
case 5:
activity.setTheme(R.style.AppThemeYellow);
break;
}
}
I am using NavigationView in drawer and drawer is coming below status bar no problem with that. But status bar is not picking up current theme's primaryDark-color. It always takes Default theme(startup theme) color only.
Setting the theme via setTheme(int resId) in the onCreate() method won't have any effect on the StatusBar since it is not part of the Activity itself afaik.
So in order to achieve the desired effect you need to do it programatically. Here's a snippet which resolves the R.attr.colorPrimaryDark and sets it for the StatusBar if the SDK-Level is above 21:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init();
setContentView(R.layout.activity_management);
// Further code
}
private void init(){
// Set the Theme
setTheme(R.style.MyAppTheme);
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
getWindow().setStatusBarColor(getAttributeColor(R.attr.colorPrimaryDark));
}
}
// Resolve the given attribute of the current theme
private int getAttributeColor(int resId) {
TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(resId, typedValue, true);
int color = 0x000000;
if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
// resId is a color
color = typedValue.data;
} else {
// resId is not a color
}
return color;
}
Edit
This approach obviously overwrites the color which is set via android:statusBarColor. So if you're using a NavigationDrawer and you want that the Drawer goes "under" the StatusBar you have to set the StatusBar color to transparent manually as soon as the Drawer is opened:
Example
actionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar,
R.string.open_drawer_accessibility_desc,
R.string.close_drawer_accessibility_desc) {
#SuppressLint("NewApi")
#Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(
getResources().getColor(android.R.color.transparent));
}
}
/** Called when a drawer has settled in a completely open state. */
#Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
/** Called when a drawer has settled in a completely closed state. */
#Override
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
}
};
}
I've done a few researches on this topic and I couldn't find a complete solution so, step by step and with some trial and error, I finally find out how can we achieve these results: having a transparent or coloured Actionbar and Statusbar. See my answer bellow.
I'm developing an app that needs to look similar in all devices with >= API14 when it comes to actionbar and statusbar customization. I've finally found a solution and since it took a bit of my time I'll share it to save some of yours.
We start by using an appcompat-21 dependency.
Transparent Actionbar:
values/styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light">
...
</style>
<style name="AppTheme.ActionBar.Transparent" parent="AppTheme">
<item name="android:windowContentOverlay">#null</item>
<item name="windowActionBarOverlay">true</item>
<item name="colorPrimary">#android:color/transparent</item>
</style>
<style name="AppTheme.ActionBar" parent="AppTheme">
<item name="windowActionBarOverlay">false</item>
<item name="colorPrimary">#color/default_yellow</item>
</style>
**values-v21/styles.xml**:
<style name="AppTheme" parent="Theme.AppCompat.Light">
...
</style>
<style name="AppTheme.ActionBar.Transparent" parent="AppTheme">
<item name="colorPrimary">#android:color/transparent</item>
</style>
<style name="AppTheme.ActionBar" parent="AppTheme">
<item name="colorPrimaryDark">#color/bg_colorPrimaryDark</item>
<item name="colorPrimary">#color/default_yellow</item>
</style>
Now you can use these themes in your AndroidManifest.xml to specify which activities will have a transparent or colored ActionBar:
<activity
android:name=".MyTransparentActionbarActivity"
android:theme="#style/AppTheme.ActionBar.Transparent"/>
<activity
android:name=".MyColoredActionbarActivity"
android:theme="#style/AppTheme.ActionBar"/>
Note: in API>=21 to get the Actionbar transparent you need to get the Statusbar transparent too, otherwise will not respect your colour styles and will stay light-grey.
Transparent Statusbar (only works with API>=19):
This one it's pretty simple just use the following code:
protected void setStatusBarTranslucent(boolean makeTranslucent) {
if (makeTranslucent) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
But you'll notice a funky result:
This happens because when the Statusbar is transparent the layout will use its height. To prevent this we just need to:
SOLUTION ONE:
Add this line android:fitsSystemWindows="true" in your layout view container of whatever you want to be placed bellow the Actionbar:
...
<LinearLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</LinearLayout>
...
SOLUTION TWO:
Add a few lines to our previous method:
protected void setStatusBarTranslucent(boolean makeTranslucent) {
View v = findViewById(R.id.bellow_actionbar);
if (v != null) {
int paddingTop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? MyScreenUtils.getStatusBarHeight(this) : 0;
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true);
paddingTop += TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
v.setPadding(0, makeTranslucent ? paddingTop : 0, 0, 0);
}
if (makeTranslucent) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
Where R.id.bellow_actionbar will be the layout container view id of whatever we want to be placed bellow the Actionbar:
...
<LinearLayout
android:id="#+id/bellow_actionbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</LinearLayout>
...
So this is it, it think I'm not forgetting something.
In this example I didn't use a Toolbar but I think it'll have the same result. This is how I customize my Actionbar:
#Override
protected void onCreate(Bundle savedInstanceState) {
View vg = getActionBarView();
getWindow().requestFeature(vg != null ? Window.FEATURE_ACTION_BAR : Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(getContentView());
if (vg != null) {
getSupportActionBar().setCustomView(vg, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayUseLogoEnabled(false);
}
setStatusBarTranslucent(true);
}
Note: this is an abstract class that extends ActionBarActivity.
It supports after KITKAT. Just add following code inside onCreate method of your Activity. No need any modifications to Manifest file.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); // in Activity's onCreate() for instance
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
Just add these lines of code to your activity/fragment java file:
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
);
I know it's possible to have it so if I have a setting I can change between Holo.Light and Holo, however, I cannot seem to find out how. All help is appreciated!
I think that you can do it by using the setTheme() method. Just make sure that you call it before you use setContentView, or it won't work.
For example:
if(userChoice ==1){
setTheme(android.R.style.Theme_Holo_Light);
else if(userChoice == 2){
setTheme(android.R.style.Theme_Holo);
}
A list of themes can be found here
As per a comment on the answer posted, if you need to toggle between the default Holo Themes, use this:
if (mThemeId == R.style.AppTheme.Dark) {
mThemeId = android.R.style.Theme_Holo_Light;
} else {
mThemeId = android.R.style.Theme_Holo;
}
this.recreate();
To use your own custom defined themes from your Styles.XML file. For example, something like this:
<style name="ActionBar" parent="#android:style/Widget.Holo.ActionBar" />
<style name="ActionBar.Light" parent="#style/ActionBar">
<item name="android:background">#color/actionbar_background_light</item>
</style>
<style name="ActionBar.Dark" parent="#style/ActionBar">
<item name="android:background">#color/actionbar_background_dark</item>
</style>
<style name="AppTheme.Light" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar.Light</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="listDragShadowBackground">#android:color/background_light</item>
<item name="menuIconCamera">#drawable/ic_menu_camera_holo_light</item>
<item name="menuIconToggle">#drawable/ic_menu_toggle_holo_light</item>
<item name="menuIconShare">#drawable/ic_menu_share_holo_light</item>
</style>
<style name="AppTheme.Dark" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/ActionBar.Dark</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="listDragShadowBackground">#android:color/background_dark</item>
<item name="menuIconCamera">#drawable/ic_menu_camera_holo_dark</item>
<item name="menuIconToggle">#drawable/ic_menu_toggle_holo_dark</item>
<item name="menuIconShare">#drawable/ic_menu_share_holo_dark</item>
</style>
Define this as a Global Variable in your Activity:
private int mThemeId = -1;
And set your onCreate() method like this:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null) {
if (savedInstanceState.getInt("theme", -1) != -1) {
mThemeId = savedInstanceState.getInt("theme");
this.setTheme(mThemeId);
}
mTitlesHidden = savedInstanceState.getBoolean("titlesHidden");
}
setContentView(R.layout.main);
}
And the code to toggle between the two themes:
if (mThemeId == R.style.AppTheme.Dark) {
mThemeId = R.style.AppTheme.Light;
} else {
mThemeId = R.style.AppTheme.Dark;
}
this.recreate();
Note: The theme has to be set before your call to setContentView()
NullPointerException when long-press over field
compile 'com.android.support:appcompat-v7:19.1.+'
XML
<EditText
android:id="#+id/field"
style="#style/Field"
android:textSize="20sp"
android:hint="#string/hint"
android:nextFocusDown="#+id/other"/>
Style
<style name="Field" parent="Theme.AppCompat.Light">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/blue</item>
<item name="android:singleLine">true</item>
<item name="android:gravity">center_vertical</item>
<item name="android:inputType">textCapCharacters|textNoSuggestions</item>
<item name="android:imeOptions">actionNext</item>
<item name="android:popupBackground">#color/white</item>
</style>
LogCat
java.lang.NullPointerException
at android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:302)
at android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
at android.support.v7.app.ActionBarActivityDelegate.getActionBarThemedContext(ActionBarActivityDelegate.java:208)
at android.support.v7.app.ActionBarActivityDelegateICS.onActionModeStarted(ActionBarActivityDelegateICS.java:195)
at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onActionModeStarted(ActionBarActivityDelegateICS.java:359)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2437)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2362)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
at android.view.View.startActionMode(View.java:4554)
at android.widget.Editor.startSelectionActionMode(Editor.java:1551)
at android.widget.Editor.performLongClick(Editor.java:859)
at android.widget.TextView.performLongClick(TextView.java:8373)
at android.view.View$CheckForLongPress.run(View.java:18441)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
The ActionBar is null. That's because you're using an activity without a title (and thus also without an actionbar):
requestWindowFeature(Window.FEATURE_NO_TITLE);
There are two ways to fix it.
Simple:
Make YourActivity NOT extends ActionBarActivity but normal Activity.
More difficult:
Make transparent ActionBar with no title, no icon, no home button etc. How to do this? First, define ActionBar style and new theme that extends YourAppTheme:
<!-- Your App Theme-->
<style name="YourAppTheme.Light" parent="#style/Theme.AppCompat.Light">
<...>
</style>
<!-- Transparent ActionBar Style -->
<style name="YourAppTheme.Light.ActionBar.Transparent" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#android:color/transparent</item>
<item name="background">#android:color/transparent</item>
</style>
<!-- Fullscreen Activity Theme -->
<style name="YourAppTheme.FullScreen.Light" parent="#style/YourAppTheme.Light">
<item name="android:actionBarStyle">#style/YourAppTheme.Light.ActionBar.Transparent</item>
<item name="actionBarStyle">#style/YourAppTheme.Light.ActionBar.Transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="windowActionBarOverlay">true</item>
</style>
Next, set this theme to your fullscreen activity:
<activity
android:name="your.package.name.YourFullscreenActivity"
android:label="#string/app_name"
android:theme="#style/YourAppTheme.FullScreen.Light" />
Finally, add following lines to YourFullscreenActivity#onCreate method:
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
I hope it will help.
I think I have a better solution to this issue.
Remove requestWindowFeature(Window.FEATURE_NO_TITLE); from activity and <item name="android:windowNoTitle">true</item> from activity theme.
To your activity code add:
To onCreate() method
View actionBar = getActionBarView();
if (actionBar != null) {
actionBar.setVisibility(View.GONE);
}
To activity class:
public View getActionBarView() {
Window window = getWindow();
View v = window.getDecorView();
int resId;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
resId = getResources().getIdentifier(
"action_bar_container", "id", getPackageName());
} else {
resId = Resources.getSystem().getIdentifier(
"action_bar_container", "id", "android");
}
if (resId != 0) {
return v.findViewById(resId);
} else {
return null;
}
}
#Override
public void onSupportActionModeStarted(ActionMode mode) {
super.onSupportActionModeStarted(mode);
View actionBar = getActionBarView();
if (actionBar != null) {
actionBar.setVisibility(View.VISIBLE);
}
}
#Override
public void onSupportActionModeFinished(ActionMode mode) {
super.onSupportActionModeFinished(mode);
View actionBar = getActionBarView();
if (actionBar != null) {
actionBar.setVisibility(View.GONE);
}
}
This is remove action bar and at the same time allows you to manipulate text in edit text with action mode buttons.
Cheers
The second solution to the above answer works, but causes the top row that would have been covered by the actionbar to be unclickable. Set the height item to zero in the actionbar style to solve this issue:
<item name="android:height">0dp</item>
I think erakitin is a VERY good answer, and quiet simple if you take the "DO NOT extend ActionBarActivity, but in case anyone needs or want to avoid making that change, I'm leaving another answer which I think is also very simple and solves the problem PERFECTLY.
Try adding this to your activity's theme.
<item name="android:windowActionBar">false</item>
public class MainActivity extends ActionBarActivity
Change to:
public class MainActivity extends Activity