How to hide toolbar with drawer layout and still be be able to use the open drawer button(three lines)? - hide

I'm new to android and I'm trying to hide toolbar in drawer
layout for a time now but couldn't do it.If I change primary
color to 0 opacity then I get "A TaskDescription's primary
color should be opaque" error I know the reason of the error
so I've to set 255 opacity to primary color as taskDescription
takes primary color. I want the following UI;
[UI1
I've used following theme;
<!-- 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="NoActionBar" 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>
manifest ;
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/NoActionBar"
android:supportsRtl="true">
<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>
I did manage to transparent the status bar by setting up primaryDark color to opacity 0.
color.xml ;
<?xml version="1.0" encoding="utf-8"?><resources>
<color name="colorPrimary">#3f51b5</color>
<color name="colorPrimaryDark">#00303f9f</color>
<color name="colorAccent">#FF4081</color>
<color name="toolbarcolor">#00ffffff</color>

Use tooolbar.hide() method or instead you can use scrollbars to whole activity with toolbars so that it will give a hide toolbar behaviour
or just give a trasparent color to toolbar
I hope it will help a little bit

Related

Android Style Base.V7.Theme.AppCompat.Light set as default and is not a Theme

i have a project in Android Studio where my manifest Have this:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:theme="#style/Theme.Glin"
android:supportsRtl="true">
<activity
android:name=".MainActivityJava"
android:exported="false" />
<activity android:name=".MainActivity"></activity>
<activity
android:name=".location.LocationActivity"
android:exported="false"
android:label="Location" />
<activity
android:name=".activity.RepairTagActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.UHFMainActivity"
android:exported="false"
android:label="Main"/>
<activity
android:name=".StartActivity"
android:exported="true"
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>
my thEmes:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Glin" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/low_blue</item>
<item name="colorPrimaryVariant">#color/gray</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/ligth_blue</item>
<item name="colorSecondaryVariant">#color/middle_blue</item>
<item name="colorOnSecondary">#color/petroleum</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
<style name="Theme.Glinvergy.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.Glin.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.Glin.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="CustomTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/ligth_blue</item>
<item name="colorPrimaryVariant">#color/red</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/ligth_blue</item>
<item name="colorSecondaryVariant">#color/ligth_blue</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
and my styles have this style as one of them:
<style name="Base.V7.Theme.AppCompat.Light">
for some strange reason, when i quit this last style, my login_fragment appears without toolbar, so is fine by me, but when i put it, my login fragment appears with a toolbar and everything inside my app appears with 2 toolbars, the problems that other activity inside my app require this style. need some help with that
Invalidate cache and restart, it's not successfully , clean your project and rebuild project.

Hide navigation bar COMPLETELY (Android Studio)

There are many videos about hiding navigation bar by using setSystemUiVisibility or something like this. However, navigation bar is being showed again after using keyboard to write username or password. And probably that solution will be broken because of other things. Help me to hide navigation bar completely like in the games. My app just don't need that.
In your res/values/styles.xml file copy this style:
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
Here the parent theme is the theme you are currently using. Typically it will be in the file like this as default:
<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>
Then go to the AndroidManifest.xml and make it like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package.name">
<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="Apptheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
What you do here is change your activity's theme to Apptheme.NoActioBar theme.
Then run your app and you will have no action bar.

App Bar is not showing in Android Studio but showing on an actual android device

I have already checked similar problems like mine but none of it helped. I also checked my previous project with the same AppTheme, they are the same but I have noticed everytime I create a new android project, the App bar is not showing even after several "Rebuild Project".
This is what my styles.xml shows
<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>
</resources>
This is what my AndroidManifest.xml shows
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mycontact">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
My MainActivity.java (Haven't put code yet)
package com.example.mycontact;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
And my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
</LinearLayout>
I have also tried changing the layout from ContraintLayout, RelativeLayout but nothing has changed. Zooming in and zooming out the layout doesn't change at all. Here is a snapchat.. Thank you for your help.
activity_main.xml page
Your styles.xml and other files seem to be in order, so try the following out.
Click the "Eye" icon on the toolbar above the XML Layout Preview, and then select "Show Layout Decorations" if it is unchecked. This should make it display both the AppBar and the system navigation bar.
Screenshots for reference, taken on Android Studio 3.3:
1. Layout with decorations missing
2. Press the 'Eye' icon, and select the option
3. The decorations (AppBar and system navigation bar) should now be visible

Android action bar not reflecting color change

I've read numerous answers regarding changing the color of the action bar, but I can't seem to get it to work. Here's what I have:
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:windowBackground">#color/actionBarBackground
</item>
</style>
</resources>
I've also tried
<item name="android:Background">#F33</item>
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
You are changing the android:windowBackground not the background of your ActionBar.
In any case, starting with the AppCompat v21+, you can use a new way to customize your ActionBar.
All of your Activities must extend from AppCompatActivity
All of your themes (that want an ActionBar/Toolbar) must inherit from Theme.AppCompat.
Just use a theme like this:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">#color/my_awesome_red</item>
<item name="colorPrimaryDark">#color/my_awesome_darker_red</item>
<!-- The rest of your attributes -->
</style>
The current version of AppCompat is 23. It requires API23 to compile the project.
The following seems to have done the trick. I found it here Change Background color of the action bar using AppCompat
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:background">#color/actionBarBackground</item>
<item name="background">#color/actionBarBackground</item>
</style>
However, now my android:label in my manifest file is being covered by the background color, so I added
<item name="android:displayOptions">showTitle</item>
<item name="displayOptions">showTitle</item>

Android custom theme won't apply

For my application I want to make a custom theme with just a different color for my actionbar. So I found a theme generator on the Internet:'Android Action Bar Style Generator'. I picked some color and downloaded the theme, put my downloaded stuff in the res-folder and changed the 'style' to my new theme. For some reason my theme never applies to my application. It always uses the baseTheme which is also specified in the downloaded theme. This is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jobslot.indupac" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="#mipmap/bpi_logo_transparant_background"
android:label="Indupac"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity">
</activity>
<activity
android:name=".GraphActivity">
</activity>
</application>
</manifest>
This is my style:
<resources>
<color name="basic_text">#000000</color>
<color name="basic_text_buttons">#FFFFFF</color>
<color name="blue_bpi">#003676</color>
<color name="light_green_bpi">#D6FFDA</color>
<style
name="AppTheme" parent="#style/Theme.Indupac">
</style>
</resources>
I found a solution for my problem. When I applied the default theme "#style.AppCompat.Light.DarkActionBar" and added "colorPrimary" as an item, then it worked like a charm. Keep in mind not to put "android:" in front of "colorPrimary", because that requires API 21. Here is what i got:
<resources>
<color name="basic_text">#000000</color>
<color name="basic_text_buttons">#FFFFFF</color>
<color name="blue_bpi">#003676</color>
<color name="light_green_bpi">#D6FFDA</color>
<style
name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/blue_bpi</item>
<item name="colorAccent">#color/blue_bpi</item>
</style>
</resources>

Resources