I am using an activity to work as a dialog box. However, the actionBar on the dialog activity is not disappearing. I have tried using:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_dialog);
}
It Doesn't work. I also set the theme of the app (from the manifest) to be as following:
<activity
android:name=".DialogActivity"
android:label="#string/title_activity_dialog"
android:theme="#style/Theme.AppCompat.Light.Dialog.Alert" >
</activity>
Following is the Screen shot is of what I am getting and I am aiming to remove this pointless white bar which is hiding the text.
The Screen Shot of the Emulator
Thank you.
Create custom theme eg. CustomTheme in styles.xml
<style name="CustomTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
</style>
and in manifest.xml use
android:theme="#style/CustomTheme"
Try this:
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="windowNoTitle">true</item>
Although in theory customizing the theme with no title bar should work, however in my case it didn't work. So I solved it by removing the following section from the activity_class.xml
<android.support.v7.widget.Toolbar android:id="#+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
Related
I have a ViewPager in my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent" />
</RelativeLayout>
And I want all Fragments to be in fullscreen mode (the screen should be also under status bar). I also set in that Activity:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
and tried several thinks but nothing work. In a different Activity this code works OK.
Do you know where the problem is?
Look at the screenshot. It's still below the Status bar:
put this in style.xml
<style name="Login" parent="AppTheme">
<item name="android:windowFullscreen">true</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimary</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/white</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="colorControlNormal">#color/white</item>
</style>
and this in manifest
<activity
android:name=".ui.activities.LoginActivity"
android:theme="#style/Login"/>
For Fullscreen of Activity use fullscreen theme from manifest for that particular activity
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
.../>
or you can also apply theme programmatically using Activity.setTheme()
If you want to include your app content as a background of statusbar, it is not possible, yes in newer versions you can customize the color of statusbar background.
Remove android:fitsSystemWindows="true". That flag is used when you want to keep some components from displaying over the status and navigation bars.
I'm trying to customize the style of my application inside the SettingsActivity. I would like to change the status bar and toolbar colors, and if possible also the window background(from dark to light grey) and text colors(change white for black for example).I've read many websites and I've tried different options in the style.xml but with no success. In SettingsTheme colorPrimary and colorPrimaryDark doesn override the default color of the parenttheme. Thanks in advance.
This is the main activity of my app
and this is the settings activity i have now
style.xml
<resources>
<!-- application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#3F51B5</item>
<item name="colorPrimaryDark">#1A237E</item>
<item name="colorAccent">#FFEB3B</item>
<item name="android:windowBackground">#color/custom_background_light_grey</item>
<item name="dropDownListViewStyle">#style/PopupMenuListView</item>
</style>
<style name="PopupMenuListView" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:divider">#FF0000</item>
<item name="android:dividerHeight">2dp</item>
<item name="android:background">#3F51B5</item>
</style>
<style name="SettingsTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="colorPrimary">#3F51B5</item>
<item name="colorPrimaryDark">#1A237E</item>
</style>
</resources>
toolbar in xml
<android.support.v7.widget.Toolbar
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
</android.support.v7.widget.Toolbar>
Are you sure you use the Toolbar in settings? And may be you forgot to add "NoActionBar Theme" in Setting Activity?
(I know this may not be the answer but I couldn't comment because of the reputation.)
Please replace above code in your Settings activity toolbar code.
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
I am using Toolbar for the purpose of material design in my application. Everything working fine but except when it comes to change the menu item text color I am completely stuck up with the solution. I am also posting screenshot of the text that should be taken and code I am using in my application for your reference. I tried several alternate methods like assigning as follows
<item name="android:actionMenuTextColor">#color/white</item>
<item name="android:textColor">#000</item>
But known of the above solutions works for me.
Requirement screenshot:
Need to change SKIP menu item from black to white color.
styles.xml
<style name="ToolBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="colorPrimary">#color/blue</item>
<item name="colorPrimaryDark">#color/blue</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:actionMenuTextColor">#color/white</item>
<item name="android:textColor">#000</item>
</style>
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true"
android:background="?attr/colorPrimary"/>
manifests
<activity
android:name=".activity.HomeActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|screenLayout|orientation"
android:theme="#style/ToolBarTheme"></activity>
I really dont know where I am committing mistake. Please help me. Thanks in advance
Change this
<item name="android:actionMenuTextColor">#color/white</item>
to
<item name="actionMenuTextColor">#color/white</item>
And apply the theme to the toolbar:
android:theme="#style/ToolBarTheme"
You style your widgets and provide themes for your activity.
I have the following gradle AppCompat and activity definitions:
compile 'com.android.support:appcompat-v7:21.0.3'
<activity
android:name="MainActivity"
android:label="#string/app_name"
android:hardwareAccelerated="true"
android:screenOrientation="portrait"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
Action bar currently looks like this:
I'd like to make title and subtitle fonts bigger and also adjust an image size, how can I do that?
After some searching I've found out I should start with defining a custom Toolbar in activity XML like this:
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#color/background_material_dark"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
But once I put that code inside my activity I get the following rendering error:
So I'm kind of lost here, can someone explain what's going on and what should I do?
UPD
Following some tutorial I've tried this:
<style name="MyTheme" parent="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:subtitleTextStyle">#style/MyTheme.ActionBar.Subtitle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="MyTheme.ActionBar.Subtitle" parent="#style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColor">#FF0000</item>
</style>
And now both title and subtitle are just not visible. I suspect I should use some other parent instead of #style/Base.ThemeOverlay.AppCompat.Dark.ActionBar but I have no idea which exactly.
You can use the style Widget.AppCompat.Toolbar.
<!-- Toolbar styles -->
<item name="toolbarStyle">#style/Widget.AppCompat.Toolbar</item>
I want to disable ActionBar shadow but only in one Activity. If I use this code it will be change in whole aplication.
<style name="MyAppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowContentOverlay">#null</item>
</style>
I tried this code, but it is not working
getSupportActionBar().setElevation(0);
Any suggestion...?
You can set your own style for Activity for this:
<!-- Your main theme with ActionBar shadow. -->
<style name="MyAppTheme" parent="android:Theme.Holo.Light">
....
</style>
<!-- Theme without ActionBar shadow (inherits main theme) -->
<style name="MyNoActionBarShadowTheme" parent="MyAppTheme">
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
</style>
So in Manifest.xml you can set different style for all Activities:
<!-- Activity with ActionBar shadow -->
<activity
android:name=".ShadowActivity"
android:theme="#style/MyAppTheme"/>
<!-- Activity without ActionBar shadow -->
<activity
android:name=".NoShadowActivity"
android:theme="#style/MyNoActionBarShadowTheme"/>
Or you can set the right theme programmatically in onCreate() method:
#Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.MyNoActionBarShadowTheme);
super.onCreate(savedInstanceState);
//...
}
Add app:elevation="0dp" to appbarlayout as shown below:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/home_tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
Create a new Theme that inherits your App theme:
<style name="MyAppTheme.NoShadow" parent="MyAppTheme">
<item name="android:windowContentOverlay">#null</item>
</style>
and let your activity use this theme. In your Manifest:
<activity
android:name="...MyShadowlessActivity"
android:theme="#style/MyAppTheme.NoShadow" .../>