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.
Related
I have a fragment container view that changes the fragment based on the selection in a spinner. I want the fragments to have rounded corners. I believe adding rounded corners to fragmentContainerView will do what I need? How can I do this? I tried adding a drawable resource file(shape) to background but it didn't work.
My drawable resource file
My activity.xml code
The way it still shows in the app. The red part is the FragmentContainerView
CustomerRegisterFragment have it‘s own background which will cover the FragmentContainerView background you set.
I found out that in order for the drawable resource file to take effect, it must contain the tag <solid> with a color attribute. Then it displays as required
Currently, I have this back arrow that I'm going to use in my toolbar
What I want is to fill the middle part which a specific color which is the middle part is a transparent part.
currently what i have is this :
Drawable backArrow = getResources().getDrawable(R.drawable.ic_back);
backArrow.setColorFilter(getResources().getColor(R.color.aub_red), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(backArrow);
it only changes the color of the white color part into the red color which is wrong. what I want to fill the transparent part a color not the non - transparent part.
Used this
Drawable backArrow = getResources().getDrawable(R.drawable.ic_back);
backArrow.setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.LIGHTEN);
getSupportActionBar().setHomeAsUpIndicator(backArrow);
for more information click hear
you can use :
DrawableCompat.setTint(yourdrawable,getResources().getColor(R.color.primary));
in java code, or in xml tag :
android:backgroundTint="#color/primary"
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"
...>
Hey I would like to know how i can added such a faded color effect to my layout any help is appreciated. An example here:
Thanks
You can create a Shape Drawable with your desired gradient and set it as a background for your information view at the bottom
You can use setAlpha() method to adjust alpha level for your views and thereby get a faded effect.For handling this in xml you can use android:alpha attribute for your view.
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.