Android RelativeLayout Transparent - android

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,

Related

Change Android EditText background color

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 :)

How to change the color of a horizontal line created with a view?

I have a horizontal line created with a view like this:
<View
android:layout_width="fill_parent"
android:id="#+id/led_connection"
android:layout_height="5dip"
android:background="#fff"
android:layout_marginBottom="15dp" />
I want to know how can I change the color programatically. Because I am trying to use setBackground and setBackgroundDrawable but SDK sais me that it cannot applied to a View.
I'm getting the view with this:
View led_connection = (View)v.findViewById(R.id.led_connection);
Try:
led_connection.setBackgroundColor(0xFF00FF00);
See docs for details
If you have html colors, can try this to solve your problem.
led_connection.setBackgroundColor(Color.parseColor("#679456"));
led_connection.setBackgroundColor(Color.parseColor("html_code_colors"));
As Marcin Orlowski sais, the solution is use setBackgroundColor with an hex color with the 2 first digits that are alpha level.
I'm using for GREEN:
led_connection.setBackgroundColor(0xFF008000); // GREEN
and for RED:
led_connection.setBackgroundColor(0xFFFF0000); // RED
Thank you

How to make TextView's background to be transparent?

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.

Transparent LinearLayout on Android

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"

How to remove selected color on drag over listview

I am displaying a ListView. When I drag over it, the entire ListView is selected with a black background. How can I remove that black background?
just use in ur xml file inside ListView,
android:cacheColorHint="#android:color/transparent"
It's probably because you have a custom background for your ListView. When you scroll those, the entire list gets highlighted in a black color due to its cache color.
Add this piece of code to your ListViewand try again:
android:cacheColorHint="#00000000"
view.setBackgroundColor(android.R.color.transparent);
should be view.setBackgroundResource(android.R.color.transparent)
cause setBackgroundColor take a hex color value as parameter.
or
android:cacheColorHint = "#00000000"
use this tag for the your listView. or you can also use
listview.setCacheColorHint()
to set it programatically.
From Why is my list black? An Android optimization on the Android developers' blog:
To fix this issue, all you have to do is either disable the cache color hint optimization, if you use a non-solid color background, or set the hint to the appropriate solid color value. This can be dome from code or preferably from XML, by using the android:cacheColorHint attribute. To disable the optimization, simply use the transparent color #00000000. The following screenshot shows a list with android:cacheColorHint="#00000000" set in the XML layout file:
use this,
yourList.setCacheColorHint(Color.WHITE);

Categories

Resources