I have the folowing layout:
I want to make transparent the transparent_layout but i can't do it.
Already tried settings the background programmatically with the color: Color.TRANSPARENT but it seems it doesnt work.
Im using Android 2.3.3 SDK with SherlockActionBar.
Is there any way to set that layout to transparent?
Depending upon the degree of opacity you like, set the background color like
android:background="#00ffffff"
The first two digits are for opacity level, (aka alpha) that varies from 00 to ff (fully-transparent to fully-opaque), the remaining digits are for the desired background color. If you keep first 2 digits zero (00), then whatever color you choose for the remaining digits, doesn't matter.
In XML change the main layout's (LinearLayout) background as android:background="#android:color/transparent" and also make sure that you are not giving the background to any of its child views.
Try this:
android:background="#android:color/transparent"
Related
I'm using the amazing library MPAndroidChart. It works like a charm, except when I'm trying to change the background color of the BarData. Default color is white, and I want to change it to Transparent.
I've tried this :
Paint p1 = mChart.getPaint(Chart.PAINT_GRID_BACKGROUND);
p1.setColor(Color.RED);
and this:
<com.github.mikephil.charting.charts.BarChart
android:id="#+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"/>
... but it seems that doesnt works.
Any ideas ?
Thanks =)
Since release v1.6.5, the background of the Chart is transparent by default. Meaning, that everything in the background (chart background, other Views, etc.) that is not overlayed by data drawn into the Chart, will be visible.
If you want to change the background (color, or maybe drawable), you can either do that by changing the chart-background
in .xml (android:background="...")
by calling setBackgroundColor(...) or setBackgroundResource(...)
Another way could be to change the background of the parent layout that contains the Chart.
Code to change Background color:
chart.setBackgroundColor(Color.TRANSPARENT); //set whatever color you prefer
chart.setDrawGridBackground(false);// this is a must
if you want to Change Whole Screen Background Color
Barchart chart;
chart.setBackgroundColor(Color.rgb(0, 0, 0));//Set as a black
chart.setDrawGridBackground(false);//set this to true to draw the grid background, false if not
Happy to help Thanks
So, after some research, I've found that it's not possible yet: https://github.com/PhilJay/MPAndroidChart/issues/53
Hope It will be possible soon ! =)
I am developing an Android app. There's this issue with the EditTexts, because in some devices the "background" is white (which is the way I want it), but on others is transparent, and makes the app less professional. Here's an image with the "white background":
On other devices the edit texts that say "Yo" and "Casa" are transparent, so the words mix with the map and its pretty awful. I have tried changing the background color in the android layout xml. The closest one was I believe #drawable/white, but slightly changes the position and size of the edit text, making them look like they're one and its even worst.
Here is an example:
Is there a nice way to approach this problem? I read somewhere that an option was to add a white background image to the edit texts, but seemed like a lot of trouble.
UPDATE
I tried adding a background image, but its the same as changing the background color to any color using the android:background, the edit texts get like smaller or something. I added a blue "delimiter" to the image and this is the result:
But I want them like in the first picture, not so close one to another.
This would be the code of the edittext layout XML, the other one looks very similar. Only by adding the android:background tag changes from picture 1, to picture 3
SOLUTION
To solve this what I did was set a background image and set its height in dp as follows:
<EditText
android:id="#+id/markerTitle"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/buttonModifymarker"
android:ems="10"
android:inputType="textPersonName"
android:text="Título"
android:background="#drawable/editwhite"
>
Why don't you try setting the background of EditText programmatically?
yourEditText.setBackgroundColor(Color.WHITE);
or...
yourEditText.setBackgroundColor(Color.parseColor("#ffffff"));
simply you can add android:background="#drawable/white" attribute to your element in layout xml. you can use a lot of color resource between the double quotes (like from android color resources).
put the following image which has a solid white background in the drawable folder (it may dont appear because it's white and this page's background is white also) right click under this paragraph and select "Save Image as".
and refer to it in your layout and you will get a result like the following image
if the issue continue after trying this, please show me your layout code or email me at : mohamed_hamed4158#yahoo.com , thanks for voting my answer :)
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.
Is there a way to make an android button’s background translucent within xml code,
So the button has no background drawable?
android:background="#android:color/transparent"
You can also set your own colors:
android:background="#80000000"
The first two hex characters represent opacity. So #00000000 would be fully transparent. #80000000 would be 50% transparent. #FF000000 is opaque.
The other six values are the color itself. #80FF8080 is a color I just made up and is a translucent sort of pinkish.
The best way is to create a selector.
Set the background to the standard android transparent color.
In Code:
myButton.setBackground(getResources().getColor(android.R.color.transparent));
In xml:
android:background="#android:color/transparent"
I can't get my relativelayout to be able to be set to transparent. I have tried many different methods, custom view from class, adding android:background="#android:color/transparent" etc. They either show a white like in the picture below, or they show a solid color of whatever the hex is?
Even programmatically using '.setBackgroundColor(Color.TRANSPARENT);' results in the above picture.
Figured it out. The main LinearLayout of my view was the layout making it have a white background. I added my view under my listview in a RelativeLayout and it works great. Thanks all!
Try using this :
android:background="#00000000"
Try using #AARRGGBB instead of #RRGGBB
Do this as following:
android:background="#AARRGGBB"
becomes:
android:background="#77000000"
The first 2 (AA) will set the transparancy. Set 77 to 00 for zero transparancy,