Get full screen layout in Fragment - android

I have a main Activity, and I am loading Fragments inside it.
I do not want the ActionBar, so I have hidden it in Manifest as follows
android:theme="#style/NoActionBar"
When I populate a Fragment, the ActionBar is hidden, but it gives a black portion on the bottom of the screen and I can't even use that specific portion in my layout.
Any help?

Replace your style.xml with below code:
<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>
</resources>
and then set theme as
android:theme="#style/AppTheme.NoActionBar"

In my project we are using that kind of style:
<style name="NoActionBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#color/black</item>
</style>
in AndroidManifest.xml you set it like
<application ...
android:theme="#style/NoActionBarTheme">...

Related

Change background colour of Activity

I have created an Android project and included Navigation Drawer Activity.
But the backgrounds of the activities are black.
I know I can change the background colour to white using XML or Java. But every time I do that I need to change other views as well. I checked the styles file. But it doesn't contain any tag about the background colour.
<resources>
<!-- Base application theme. -->
<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>
</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" />
</resources>
Is there any solution for that? Thank you!
Extend your app Theme from Theme.AppCompat.Light
you can Extend your app Theme from Theme.AppCompat.Light or you can pass background color to the root view of you activity layout.

with appTheme actionbar disappears, why?

My main Activity extends FragmentActivity and if I use default app theme, actionbar disappears
Style:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowActionBar">true</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
with style in Manifest:
without android:theme="#style/AppTheme" in Android manifest:
I tried to use getActionBar().show() in FragmentActivity but it simply returns null. Why this is happening and how can I turn on actionbar using style?
Instead of extending FragmentActivity, you need the main class to extend AppCompatActivity.
for more details see That
Try like this
<resources>
<style name="CustomMaterialTheme" parent="CustomMaterialTheme.Base">
</style>
<style name="CustomMaterialTheme.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="android:textColorPrimary">#color/textColorPrimary</item>
<item name="android:windowBackground">#color/windowBackground</item>
</style>
</resources>
then use theme in manifest. Refer here: http://coderzpassion.com/android-working-with-material-design/

I can't remove the action bar from my application

I am trying to remove the Action Bar from my app, but it just won't leave. Here is what I have done:
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>
<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" />
</resources>
styles.xml v21:
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
</resources>
And the app theme is set to No Action Bar.
I also am doing this in the MainActivity.java class:
getActionBar().hide();
But that only removes it when I run the app. I would like it to be gone in the design panel.
How is that done?
But that only removes it when I run the app. I would like it to be
gone in the design panel.
Simply, use a theme without ActionBar on Android Studio's Preview:
I said that because you said it's working after compiling the app and your question was about:
I would like it to be gone in the design panel
Design panel!
But, this will only show you how to remove that ActionBar on Andorid Studio's Preview.
The thing is, it should be like this:
In Manifest:
<android:theme="#android:style/Theme.NoTitleBar">
And if it is still there, You should check if there is a Toolbar in your Layouts
You have missed parent attribute:
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Similarly:
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
And don't forget to add theme declaration in manifest using:
android:theme="#style/AppTheme.NoActionBar"
Hope this would help!!
Go to your manifest.xml on this line:
android:theme="#style/AppTheme"
delete Apptheme, than typing Theme. with a dot (.) it will show you different options of theme layouts.
follow the pictures:
This will affect only the emulator. In order to see also the effect in the activity_main.xml, just go on that tab activity and press, form the preview window, the button no the top right corner "NoActionBar" as I show in follow picture, choose form the dialog box "manifest theme" and hit OK.
this will change the preview too!
hope this will help ;)

change homeAsUpIndicator icon in android kitkat

I tried to change the default icon of HomeAsUpEnabled by editing my styles.xml file. But my icon did't changed. I am working on min sdk version:23. Below is my styles.xml file.
My styles.xml file
<!-- 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>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:homeAsUpIndicator">#drawable/back</item>
<item name="homeAsUpIndicator">#drawable/back</item>
</style>
Use the Toolbar and call toolbar.setNavigationIcon(). See more on toolbar here http://developer.android.com/reference/android/widget/Toolbar.html

How to make my app with transparrent theme?

I am making my Music player now. I want it to be lightly transparent(Android background barely visable). Structure: One activity with 4 fragments (viewPager with tabs). Any ideas?
<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" />
Just use this theme in your Activity's theme
android:theme="#android:style/Theme.Translucent.NoTitleBar"
This will make the background of your ACtivity completely transparent. You can also extend that theme and set a custom windowBackground
In your styles.xml
<style name="MyTransparentTheme" parent="#android:style/Theme.Translucent.NoTitleBar">
<item name="windowBackground">#color/my_transparent_color</item>
</style>
In case you are using AppCompat you should change the parent theme to
<style name="MyTransparentTheme" parent="#style/Theme.AppCompat.Translucent.NoTitleBar">
<item name="windowBackground">#color/my_transparent_color</item>
</style>

Categories

Resources