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"
...>
Related
I am making effort to change my cardView background color to a different color other than the default color set in style with the colorSurface property.
I am aware colorSuface is responsible for a cardView color, but it is surprisingly difficult to change it color in XML.
I have tried the following singly and together but there is no effect.
android:background="#color/purple_200"
app:cardBackgroundColor="#color/purple_200"
android:backgroundTint="#color/purple_200"
I will appreciate help.
Here is my styles code
<item name="colorSurface">#color/app10</item>
The reason I don't want to change the colorSurface property is because, that is the default desired color I want for all cardView but in this particular layout, I want to style my row of cardView widgets with tones of a color, unfortunately, it is not responding.
I figured out the issue was the color set to an imageView inside the cardView was overlaying the color of the cardView.
Another possible cause of this kind of behaviour is if the cardView was inside a layout whose elevation (layout) is possibly greater than the cardView.
Thanks #Mike M for asserting that cardView doesn't disappoint in this case.
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.
There is a tablelayout having four tablerows, the first tablerow contains a TextView :
As you can see the background of the TextView having the text "Vidy" is seen ! So how to make it transparent ? I tried to add android:alpha="0" to the attribute of the TextView but at runtime the text is not seen !
You can try:
android:background="#null"
Or:
android:background="#android:color/transparent"
Check also: Android Transparent TextView?
If you really need transparency, #Nermeen's answer is great, you can also get it done programmatically like:
myTextView.setBackgroundColor(Color.TRANSPARENT);
but as long as you have solid background color below, it's better due to performance to make your TextView's background color the same as the layout below (with alpha, app needs to redraw more regions). It won't really matter for such a simple layout, but it's worth remembering when you have many of them using transparency.
How can I override the XML attributes of TwoLineListItem. I don't want to do it Java. I'm trying to make the backgrounds of the view and the textViews transparent, but it isn't working when I do it in Java.
setBackGroundDrawable
setBackGroundColor
setBackGroundResource
These don't seem to do what I need them to do. I've tried making no background. I've tried setting an alpha value of 0 to the color, but I still get the same old white list boxes. I have a drawable background that is behind the TwoLineListItem view, and thats all I want to show for the background, not the Item background.
According to my understanding of your question you are trying to make your TextView's background to trasparent. this is what i use to do this:
TextView tv = (TextView)findViewById(R.id.textviewID);
tv.setBackgroundColor(Color.TRANSPARENT);
And I didn't get your point about TwoLineListItem. But if you want it to become single line, then write in xml properties of your TextView:
android:singleLine="true"
If this was not the question then please elaborate a bit.
How do I create a transparent textview on click at the bottom of the running screen?
Defining #00000000 the background, whereas the first 2 are it's alpha state (Transparency), and then the other 6 are RGB. Alpha is 00-FF.
Hope this helps!
If you mean make the textview invisible and being able to turn it visible, you can use this attribute in your xml textview :
android:visibility="invisible"
and then you can turn it visible with setvisibility().
now if you just want the background of your textview to be transparent, you have to define it's background color has #ffffffff