hope you guys can give me a hand now! this is tricky to me
I have run into an requirement of my application that i cant find a way to do this.
I need my application to be fullscreen and no title bar (done), and this application will have a background image. However, all the activities/views of my application must be transparent/translucent so the application background will be visible all the time behind the information i am displaying.
Basically i would like to have this behavior
http://www.geeky-gadgets.com/wp-content/uploads/2010/05/amazon-kindle-android-app.jpg
supousing that the image you see is not the phone wallpaper, but the application background image. What would be the application configuration in the manifest file and what would be the configuration for eacy activity/view?
I also noticed that, i need to setup each activity to be fullscreen without title bar. Is there a way to do this globaly in the application so all activities will behave this way?
Many thanks for your time
To hide the title bar in all your activities you should set a custom theme in your AndroidManifest.xml file like so:
<application
android:icon="#drawable/application_icon"
android:label="#string/app_name"
stuff..
android:theme="#style/MyTheme">
Then define the theme in styles.xml:
<style name="MyTheme" parent="android:Theme.Black">
<item name="android:windowNoTitle">true</item>
</style>
For the background, I'm pretty sure you can just set a the background of a ListView to point to a .PNG that you have in your resource folder (it probably has to be the exact dimensions of the screen).
Related
I want to implement Splash Screen using Jetpack Compose. In the old View system, we can just change the android:windowBackground via XML Theme.
How to do this in Compose?
As I looked into the AndroidManifest.xml, I saw that the app is still using old themes.xml for its activities.
<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/Theme.AppName">
From here I just edit the theme to apply a windowBackground
<style name="Theme.AppName" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="android:windowBackground">#color/black</item>
</style>
I did not create a new style and just use the main style. It's enough to just apply a white Surface on the root composable to hide the splash background when the activity showed up.
The Window Background is something specific to Android itself, it tells the system what background this activity draws "At All times".
For example, an activity with no view at all can still have a background, as it is defined in its theme. This is actually used for stuff like Splash Screens, as they have no UI, just a background. Since the background of an activity takes no time to draw, while the UI can get delayed.
Compose is a UI framework, and any UI will only be drawn when it's ready, meaning it will only show when the activity is ready. So a splash screen is impossible in Compose. More like, it's unrelated.
If you just want to set a background to your entire UI, maybe put the entire UI in a Box with a background. Or set the background colour in the MaterialTheme. And if you're not using a theme, just make a common Composable that's just a Box
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 ListView with some rows and a custom checkbox on the right hand side. On my OS 4.4 Nexus 4 it seems like a gentle gradient is being applied to the list row backgrounds, creating an ugly artifact on the checkboxes (they disappear half way down, and then invert for the bottom half). On other devices I don't see this problem, and I also don't see it in an OS 4.4.2 emulator.
I haven't been able to find any information online about this, so I'm not sure if it's specific to the device, or the exact OS flavor.
Is this something I can disable? If not, what advice should I give my asset designer?
Here's a screenshot:
The Holo.Light theme uses a subtle grey gradient background. It might only be more apparent on one of your devices due to the screen's contrast/brightness.
You can just set the background to solid white by using the android:windowBackground tag in your Activity's theme:
<style name="SolidWhiteTheme" parent="android:Theme.Holo.Light">
<item name="android:windowBackground">#android:color/white</item>
<item name="android:colorBackground">#android:color/white</item>
</style>
And then applying the theme to your activity in your AndroidManifest.xml like so:
<activity
android:theme="#style/SolidWhiteTheme"
...
>
...
</activity>
As Denley mentioned, the reason for this is the default background specified by the Holo.Light theme.
However, since this background is specifically affecting your ListView, I would suggest setting the background of your ListView in your xml file. Code below.
<ListView
android:background="#android:color/white">
Try specifying a background color for your activity (android:background). If the background is not explicitly set, the device may be using it's own device-specific default background, which is why the gradient is only shown on your Nexus 4 and not other devices.
I have a style I created like this:
<style name="myStyle" parent="#android:style/Theme.Dialog">
<item name="android:textColor">#FFFFFF</item>
<item name="android:background">#000099</item>
</style>
Then I created an xml and an activity, and in the manifest declared this
<activity android:name=".Try"
android:theme="#style/myStyle" >
</activity>
Then when I start this activity I have an xml with a background color (blue);
THe problem is , when I create an Alert Dialog
AlertDialog.Builder dialog = new AlertDialog.Builder....
It is also affected by this background (It looks more like a blue rectangle behind it that is bigger then the dialog and is coming out from all 4 sides).
I dont want it to be, I want to use another style for the alert dialog.
How can I disable this?
Are you saying that the background of your activity is too prominent when the dialog pops up? If so, you can blur what's in the background with the following code:
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Or are you saying that the background of your activity is being applied to the background of your dialog...?
I managed to fix that, well not entirley but to pass around it.
Instead of using:
#000099
I used
IMAGE_NAME
and I added a green rectangle image at the "drawable" folder.
This makes the background to become from an image instead of painting it, and the image does not affect the Dailog.
It will look a bit different (for example it will cover the white border as well) but it is better then before.
I have seen some posts regarding transparent menu.
I am able to change the background color of menu using the code given in the following link - Customizing the Options Menu Background
When I tried to change the background as transparent in the same code like given below, its not working
view.setBackgroundResource(R.drawable.full_trans_bg);
instead of a normal image I have tried the transparent image, but its not working.
I just want to change the background color alone not the rest. Bcas I know to get this transparent background by inflating a new layout in the onCreateOptionsMenu() but in this case I want to do everything manually, which is not a motive.
Thanks in advance.
Create a style in styles.xml
<style name="myApplicationCustomTheme" parent="#android:Theme">
<item name="android:panelFullBackground">#android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
</style>
Apply this to your manifest
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/myApplicationCustomTheme"
android:debuggable="true"
>
Also refer to this post. Is it possible to make the Android options menu background non-translucent?
I don't know the full code, but try something like this:
view.setBackgroundResource(new Drawable(new Bitmap(R.drawable.full_trans_bg).getBitmapdata());
That might help.
You can use XML background color value #00ff0000 which is transparent in itself.