Set default background behind an activity's layout - android

I have an activity with its layout set to an XML file. the root layout is a RelativeLayout and i am setting the background to this layout via rootLayout.setBackgroundResource(R.drawable.default_background);
this drawable, R.drawable.default_background has some transparency in it.
It seems as though the default background of any layout is black. when i set the background to this drawable resource, the default black background seeps through the semi-transparent drawable.
How can i change the default background behind this drawable to white instead of black?
edit: i do not want to change the theme, as that changes more than just background

Make the root view of the layout a FrameLayout which contains your RelativeLayout, and make the FrameLayout's background white.

Related

How to change app background except textview's background?

I want change background for whole app except textviews.
So, I change style.xml
<item name="android:background">#color/colorRed</item>
But textviews change background too. For example, toast text appear on red background. As I understand, default textview background is transparent. Is there posibilitiy to change background without textviews?
Just add a background (android:background) to the text view on the xml file, like this
<TextView
android:background="android.R.color.white"
That background will not change because it's fixed.

How to make parent background opaque but keep child element non opaque?

Hi guys I am new to Android .I want to make the layout given in the image.
I want to achieve the effect inside the red box.How can I make the background opaque while its keep its child opaque?
I tried this as,
The part inside the red box as RelativeLayout, which has a TextView (value as Contact details) I gave android:alpha=0.3 for relative layout,but the problem is,it makes the TextView also opaque (which is logical)
I just want some thoughts to move in that direction.
Create a color resource with an alpha component of 0.3 and set it as the background of the RelativeLayout
In the colors.xml
<color name="opaque_black">#4c000000</color>
In the layout of the View
<RelativeLayout
...
android:background="#color/opaque_black"
...>

setting shape and transparency of fragment in android activity

I have an activity in android and I want to add a fragment which would appear as in the image below. I want it to have the shape shown and be semi-transparent so that the activity can be seen in the background. Two questions : 1) How do I set the shape of a framelayout? I assume I define the shape in XML and save it as a XML file but which attribute do I use to set the frame layout to have that shape. 2) how do I make the fragment semi transparent, I assume I would use a semi transparent color as the background, but I am not sure.
For transparency, use alpha=" (float) value" on your fragment layout (container) in your activity_main.xml.
For rounded corners check this solution this solution, adding background also on fragment layout container. Also apply padding to this container.

background color of custom notification with image buttons is black in 3.1 emulator

I have custom notification with linear layout that contains four image buttons.
I set the linear layout background color to transparent color #00000000 and also i set the background color of the four image buttons to transparent color #00000000.
As Expected, According to the transparent color of linear layout and image buttons, my custom notification background color must match the emulator notification background color(almost gray).
but actually the background of notification is still black.
My minimum sdk is 11 and target is 19
Note that the other previous questions not solved my problem.
Thanks in advance, Mostafa.
Try to use in your XML file
android:background="#android:color/transparent"
instead of #00000000

Android Application : Background Image over Background Color

I am new to android development and am developing my first android application. I have the background color of the View set in the layout's xml as follows.
android:background="#+color/bgColor"
Now, i have a full sized transparent background image that i want to lay over the background and then other Elements over that image.
is there a way i can use both background color and background image in the same layout.
Thanks in Advance.
You can use an ImageView with a background color:
<ImageView
layout_width="match_parent"
layout_height="match_parent"
src="#drawable/myImage"
background="#color/myBgColor" />
Another option is to set the background color in the root element of your layout, and keep the src in your ImageView.
I'm using AppCompatImageView. In this background color can be set using the below property.
android:backgroundTint="#color/colorPrimary"

Categories

Resources