user1480067
user1480067

Reputation: 43

Transparent edit text view is different in 2.3 version and 4.2 version

I'm struggling with a small problem, my question is I am using a transparent edit text view in the design part, in 4.2 version android device looking fine well and good, if I check that same edit text in 2.3 version and below version showing a black coloured edit text. this is my edit text code.

<EditText android:id="@+id/name"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_margin="5dip"
          android:layout_weight="1"
          android:alpha="0.3"
          android:background="@drawable/reg_edittext"
          android:ellipsize="end"
          android:ems="10"
          android:lines="1"
          android:scrollHorizontally="true"
          android:singleLine="true"
          android:textColor="#ffffff" />

here is my reg_edittext

<?xml version="1.0" encoding="utf-8"?>
<!--  res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"  >
<solid android:color="#000000" />
    <corners android:bottomRightRadius="5dp"
             android:bottomLeftRadius="5dp"
             android:topLeftRadius="5dp"
             android:topRightRadius="5dp"/>
</shape>

showing a black coloured edit text in 2.3 version, in 4.2 showing transparent. answer me I would like to view same transparent in 2.3 version

Upvotes: 3

Views: 1083

Answers (3)

Suji
Suji

Reputation: 6044

You must specify alpha also while specifying the color if you want to give any transparency for the same. So the total color value should be in the format #AARRGGBB where AA - is the alpha color value (00 - transperant, FF- opaque) , RR - red color, GG - green color, BB- Blue color. In your case to get complete transperant background gou have to specify like this:

android:textColor="#00000000"

Upvotes: 0

MH.
MH.

Reputation: 45503

Although @Sri's answer is mostly correct, it's not complete. You're seeing an opaque black background because the following attribute wasn't added until API level 11 (Android 3.0):

Fortunately, you can add transparency to colors. To make the background color translucent, with the same 0.3/30% alpha value, change the solid declaration to:

<solid android:color="#4C000000" />

Upvotes: 3

Srinivasan
Srinivasan

Reputation: 4661

please check the link

 android:alpha="0.3" this alpha property is added in API level 14. So in the previous version it map looks different depends on devices.

Try to change the backgroud solid color as transparent it may help you out.

android:color="#000000" to transparent color range- #FF000000 to #00000000

Upvotes: 2

Related Questions