I want the background of my textView or Linear layout to be translucent. I have attached an image as an example of what I want to achieve.
translucent http://imagecdn3.maketecheasier.com/2011/03/kde-style-oxygen-transparent.jpg
I don't want to make the whole activity translucent but just a layout field in it. How can I get this?
See Translucent theme, descibed here:
http://developer.android.com/guide/topics/ui/themes.html
create an activity
set activity’s theme as “#android:style/Theme.Translucent” in AndroidManifest.xml
that’s all
Check this for more details.
For making the activity Completely transparent,
main.xml-
android:background="#android:color/transparent"
manifest.xml-
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
For making activity Translucent
#00FFFFFF - Full Transparency
#10FFFFFF - 90% Transparency
#20FFFFFF - 80% Transparency
#30FFFFFF - 70% Transparency
#40FFFFFF - 60% Transparency
#50FFFFFF - 50% Transparency
#60FFFFFF - 40% Transparency
#70FFFFFF - 30% Transparency
#80FFFFFF - 20% Transparency
#90FFFFFF - 10% Transparency
#99FFFFFF - 01% Transparency
Usage- in layout.xml,
android:background="20FFFFFF"
here "20" is transparency and "FFFFFF" is color
Get HTML color codes from http://html-color-codes.info/
Related
I want to fill the background of multiple size (custom width or height) constraint layouts with this design:
Noticed that the outline border is glowing with fading gold color.
I have tried with the following:
Attempt (A) is using of ImageView tag, but not scalable to custom width and height.
Attempt (B) is xml created. But the border color is not fading, isn't the desired result.
Attempt (C) is using 9 patch file. The border radius and corner radius does not seems correct at all. (Would also like to know reason of this)
This is my 9patch file:
May I know if this is even possible to achieve?
Anyone please help.
Consider these 2 screenshots. I defined the elements on the left, top, and bottom-right:
The left/top screenshot has all my elements using a solid white (#FFFFFF) while the bottom/right one adds a bit of transparency (#D0FFFFFF). My issue is that my elements look hideous with transparency. For example the FAB (bottom-right) contains a smaller opaque circle for no reason.
All my elements have elevation 6 (as that is the FAB default elevation). Anything greater-than elevation 2 has this issue clearly visible, and anything below 2 does not cast enough shadow for me to look acceptable.
The Maps-defined element (top-right) seems completely unaffected by this however! What is it doing differently? It's clearly using transparency like me and also casting a shadow corresponding to elevation 2 or more.
Code used is basically this:
fab = FloatingActionButton(this.context!!)
fab.backgroundTintList = ColorStateList.valueOf(Color.parseColor("#d0ffffff"))
fab.compatElevation = 6F
For example the FAB (bottom-right) contains a smaller opaque circle
for no reason.
later on... fab.compatElevation = 6F
The circle you are seeing it's FAB's shadow, which is generated by the elevation.
If you want to remove the shadow but keep the elevation, do:
fab.outlineProvider = null
If you want to keep both elevation and shadow, you have to make a custom outlineProvider (probably a banana shaped one).
How to make background opacity of the View (for ex. EditField )with transparent, infliction, subtraction "Screen" like it is in Photoshop?
I know if I set background to "#android:color/transparent" for EditField then white background will be visible, but not main backgrounf of the layout
I need to implement this one:
You can't do it simply.. not by any code.. the only way to do that is to get a drawable .png image(you need photoshop to create it) that has this shape(semi tranaparent on the frame ans fully transparent inthe center with rounded corners).. make it with small width .. and use 9patch tool for stretching (so you can get flexible width)...
I use this tag to set background
android:background="#drawable/image_name"
how to make that?
There are two ways you can go about changing the transparency of your background image. The first is by modifying the XML layout and the second is programmically.
You can do it in XML by using the code:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/image_name"
android:alpha=".75"/>
Where android:alpha="" is your transparency with 1 as fully solid and 0 is completely transparent. More information is at the Android documentation.
(This will also work with the background of your view if that's what you want)
You can also change the transparency of it programmically (assuming you are using an ImageView).
To do this you can use the following code for the background of your view
int transparency = 100;
mView.getBackground().setAlpha(transparency);
The transparency runs from 0 to 225 where 0 is transparent and 225 is solid.
int transparency = 51 //0-255 (51 is 20% transparent)
nameOfYourView.getBackground().setAlpha(transparency);
Is it possible to have your android activity run on top of the current running activity in a transparent mode so you can see through it the activity below it? If possible, can you have different levels of transparency?
You can apply a dialog theme or a translucent theme to your activity. More info here: Styles and Themes under the "Apply a theme to an Activity or application" section.
In manifest.xml
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
In Main.xml
android:background="#20FFFFFF"
#00FFFFFF - Full Transparency
#10FFFFFF - 90% Transparency
#20FFFFFF - 80% Transparency
#30FFFFFF - 70% Transparency
#40FFFFFF - 60% Transparency
#50FFFFFF - 50% Transparency
#60FFFFFF - 40% Transparency
#70FFFFFF - 30% Transparency
#80FFFFFF - 20% Transparency
#90FFFFFF - 10% Transparency
#99FFFFFF - 01% Transparency
20 is transparency level and FFFFFF is color