I apologize to ask this question once because the previous solution couldn't address my problem.First I have set my style file with:
<item name="android:windowTranslucentStatus">true</item>
Then I included that style inside my activity in android manifest file.
After this is done I achieved my transparent status bar.But the activity details gone behind the actionbar. Then some one suggest me to put this code inside my parent view as
android:fitsSystemWindows="true"
This changed my status bar to dark grey(not transparent).I got confused what to do?I just wish to change my status bar to transparent.
From this post's answer. He has a solution to transparent stats/tool bar
Android transparent status bar and actionbar
Related
I have created 2 fragments and made them overlap using bottom sheet. First one fragment opens, then the second framgment opens, but when the 2nd fragment is closed,the colour of the status bar icons change to white if the status bar background is white and same for dark.
How do I fix this? Or how do I change the colour of status bar icons?
I have read the docs and read about WindowInsetsController but this will do it for android R only. My issue persists for all versions.
Please help.
You can't change the icons with a specific color but with that in your styles.xml file you can make it light or dark. Keep in mind that it only works API 23 and above.
<item name="android:windowLightStatusBar">true</item>
More references or ways of individual solutions you can find at this post.
The primary color of my application is white and hence my navigation bar color is also white. My problem is that navigation bar buttons are also white in color. How do I make sure that buttons are visible in white background. The app theme I have used is Theme.AppCompat.Light.DarkActionBar.
I have tried using different theme but none seem to be working so far.
Can anyone tell me how I could resolve this issue?
For Android Oreo and above you can try this:
View.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
For this to take effect, the window must request FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS but not FLAG_TRANSLUCENT_NAVIGATION.
You can also refer here for more details: https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
Also there is another approach:
you can achieve it by placing this in your theme:
<item name="android:windowLightNavigationBar">true</item>
I want to customize navigation drawer app compact action bar, I want to remove app icon from that and want to make its title center in action bar.
I have applied all solutions , but nothing is working with all the conditions.
Please give me some clue for applying it correctly
You should creat a customize action bar. Then, if you want you can add a button that can open and close your drawerlayout.
I have solved my problem. As mentioned, I have two problems, and I solved that in following way :
1) For making title centre, we need to make custom layout of action bar, and need to remove action bar title.
2) for remove app icon from action bar, we need to set android:icon property of that activity in manifest with transparent image or colour.
I have an application which uses a custom title bar. However, when my application launches, I noticed that the default title bar is shown for a brief period of time. My problem is I don't want to show the default title bar while my application is loading. How do I hide the title bar while my application is loading so that there will be no hint of it and then show it afterwards?
So far, I tried the following solutions but none have worked:
Hide the title bar in XML and then set the custom title bar in code. (Problem encountered: I received an error message saying: "You cannot combine custom titles with other title features".)
In XML:
<item name="android:windowNoTitle">true</item>
In onCreate method:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
//... some code goes here
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_header);
Set the size of the title bar in XML to 0. Then change it's size via code later. (Problem encountered: I don't know how to set the size of title bar in code. Is it possible? I tried getWindow().setAttributes() and getWindow().setLayout() but both of them didn't worked.)"
In XML:
<item name="android:windowTitleSize">30dp</item>
Modify windowTitleBackgroundStyle and set a transparent drawable as background. (Problem encountered: The content of the title bar became invisible but a line below the title bar is still visible.)
In XML:
<!-- style used by windowTitleBackgroundStyle -->
<item name="android:background">#drawable/transparent</item>
Some explanations for what you've encountered, hopefully they help lead you in a direction you're happy with.
You've already seen that your theme is used to generate what you see during activity loading. What's happening is the system is generating a temporary/loading window based on your activity's theme as specified in your manifest while your process is still starting up. Your code may not even be running yet, and your own activity will have a different window. This is significant because a number of settings become locked in once the window's decor has been created, but you actually have two chances here. The window your activity uses hasn't been created yet when you see this loading state.
Setting no title in your theme isn't working because it maps to the window feature Window.FEATURE_NO_TITLE. This dominates over any other title window features you may request and once a feature is requested you can't un-request or remove it regardless of whether decor has been initialized yet.
As part of your theme, the title size is giving you predictable issues. Theme attributes can't be changed. However, which theme your activity is using can be changed before your window decor has been initialized. You can specify one theme in your manifest for the activity that will be used during loading and swap it out using setTheme on your activity. (Best place is probably in onCreate before setContentView, where you would otherwise request window features.)
Chances are the line below the title bar you're seeing is the android:windowContentOverlay - the drawable used to supply the drop shadow from the title bar over the content. On most devices the top edge of this shadow would probably appear as a line below the title bar area. You can set this to #null to get rid of the shadow entirely if you want.
What I've done is set the following in my 'application' tag in my manifest.
android:theme="#android:style/Theme.NoTitleBar"
And then, for each activity, I added
android:theme="#style/CustomTheme"
can you try to open application in full screen mode..then on load of application you can exit full screen.that way your title bar will not be visible while in full screen mode. This works in html.not sure if you can use this trick.
I'm now customizing theme through some framework files. The problem is that I've made the status bar with transparent background. But there's an obvious side line between status bar and the application. How can I merge them together? Looks like the application align to the top of the screen but the status bar also exist.
Thanks in advance.
Please find WindowManager.LayoutParams.TYPE_STATUS_BAR in StatusBarService.java and replace it with WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY.
I think it is what you want.