I am making an app which has a widget, which has a black background. The alpha of the black background can be changed in a widget config screen from transparent to fully opaque black.
My question is about the config activity. Id like to show the widget in the middle of the screen, with its area transparent, so the home screen behind it is visible, so the user can pick which alpha suits it the most. Kind of like the music player Shuttle has it. How can it be done? Can I somehow take a screenshot of the background without all the icons, or do I somehow get a reference to the home screen background?
Thanks a lot!
okay Ive got it, what you need to do is use this in the config theme
<style name="MyWidgetConfigTheme" parent="#style/AppTheme">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowShowWallpaper">true</item>
</style>
Related
I'm using the SVGOMG-TWA Trusted Web Activity example from the Google Labs example (https://github.com/GoogleChromeLabs/svgomg-twa). How do I remove this white bar above the navigation bar? In this example, in styles.xml is configured only for the parameters of the splash screen that appears before loading the site view itself. The site itself is dark, as well as the colors of all the panels in the app. During the display of the splash screen, this band is missing, so I came to the conclusion that this is either part of the "site browsing activity" itself, or it does not fill the entire height of the screen and there is a free space, which is painted white. All colors in #color are dark.
Here is the styles styles.xml:
<resources>
<!— Theme to create a blank screen while the TWA is opening —>
<style name= "Theme.LauncherActivity" parent="Theme.AppCompat.NoActionBar">
<item name= "android:windowIsTranslucent">true</item>
<item name= "android:windowBackground">#color/colorPrimaryDark</item>
<item name= "android:statusBarColor">#color/colorPrimary</item>
<item name= "android:navigationBarColor">#color/colorPrimary</item>
<item name= "android:backgroundDimEnabled">false</item>
</style>
</resources>
And this is a part of the AndroidManifest AndroidManifest.xml:
<meta-data android:name= "android.support.customtabs.trusted.STATUS_BAR_COLOR"
android:resource="#color/colorPrimary" />
Thus, the example sets the color of the status bar for the site viewing itself after the splash screen is displayed, but if you set the background color in the same way, nothing changes and the white bar still remains.
I attached a screenshot of the app with the opened site and this white line:
https://i.stack.imgur.com/0OhZH.png
I also tried to look for other examples of TWA implementation, but they also had this band and they themselves were not functional. If you know of other ways to implement a PWA application without using Chrome and standard WebView, then I would be very happy to learn about them.
If the device has a battery charge of less than 10%, the page itself reloads and this white bar is removed. The color of the Status Bar also changes to light gray, although the color is specified for it. Maybe it's connected in some way.
I would be very grateful for any help!
This is not currently possible. There's a feature request for this to be implemented here: http://crbug.com/1021436
I have a freshly created Flutter app, and I configured my splash screen to display some background color and app icon in the middle.
By default, Android splash starts with status bar that looks dark semi-transparent. I wanted to change the color to be the same as splash background. I managed do this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowBackground">#drawable/launch_background</item>
<item name="android:colorPrimaryDark">#color/splash_color</item>
<item name="android:statusBarColor">#color/splash_color</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
</resources>
It works, but only for the few first milliseconds. After that, the logo jumps up a little and status bar appears again. This happens before main method even starts.
How can I setup this so that status bar looks exactly the same from the start, until home page is shown?
EDIT:
I prepared source code: https://github.com/szotp/splash_status_problem
The jump up does not appear in completely now project for some reason, but this semi transparent background can be seen.
#szotp, i had similar issue when i tried to implement splash screen so i used flutter_native_splash package instead. It auto-generates native code for splash screens, all you need to do is provide image and color. It will merge your status bar with same color as your screen background color. Not sure what yours look like but it worked really well for me.
In my layout there is an AdView. When I choose Dark Theme with background color as black (#292929) in offline mode, there is a black blank space at the place of AdView. AdView shouldn't be there unless there is internet connection. So, my text is covered by that blank space. But if I don't assign any background color, everything is okay. Now, how can I remove this blank black space due to AdView when background color is black?
<style name="AppTheme.Dark" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:background">#292929</item>
<item name="android:textColor">#FFFFFF</item>
</style>
Additional problem: during black background color, when I use magnify glass whole screen becomes black
I have figured out the solution. I should delete it now but might be helpful for others. Instead of choosing background, windowBackground color code solve the problem.
<item name="android:windowBackground">#android:color/black</item>
I'm new to Android studio and I figured out how I can send my application to my phone. The problem is, In the preview, At the bottom, it has this auction bar (See photo) Is there a way to get rid of that? Because my phone (Samsung Galaxy S6 Edge) Does not have that, And it sits in the way if I want to place something at the very bottom. Because in android studio it may be at the very bottom, But on my phone, it isn't.
Also, Is there a way to make that top bar, That is now black, Sort of transparent? So it takes the colour of the background? You see it in a lot of apps. As I mentioned, I'm very new in android studio so sorry.
Thanks in advance
The control bar at the bottom is part of the emulator aka any phone without hard buttons. You can toggle to full screen and it will hide it for you.
For example code simply create new activity and select fullscreen activity. You will see that it manages it by touch of surface to reappear and timer to dissappear. Just remove that bloat and handle it yourself. Done !
As for the status bar at the top, it uses your activity default background. So if you want to change this go to your styles and add a background to your AppTheme and this will be the default background color of unspecified areas instead of black.
Example:
<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:windowBackground">#color/blue</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
The windowBackground color will drive the background color of unspecified areas unless you override the theme on any particular activity in the manifest. Goodluck.
Noob question for all of you
So I have set up an ImageButton to my app but the problem is the white back ground of my picture clashes with the white default background of the android app. can someone please tell me the default hex color of an android background
There is no "default background" of an Android app. It all depends on the theme of the device.
You have 2 options:
1) Override the background of your app's activity to your own color or drawable. You can do this using the android:windowBackground attribute of your theme. See the docs. Example:
<style name="MyTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:windowBackground">#drawable/grey_background_pattern</item>
</style>
2) You should be using transparent pixels in your image instead of white. This way your image will better fit with the other colors/backgrounds of your app.