1

I have a custom listView which is built from the following row item layout. What i need is for the background to be semi-transparent. I can do this as shown in the code below using the Alpha attribute and setting it to 0.5. However, what this also does is make my textView and imageView semi-transparent too.

How can i just make the background colour semi-trans, but have the text and image normal/opaque?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:background="#ffffff"
    android:padding="8dp"
    android:alpha="0.5">

    <ImageView
        android:id="@+id/Image"
        android:layout_width="110dp"
        android:layout_height="90dp"
        android:layout_marginRight="6dip"/>

    <LinearLayout
        android:id="@+id/Text"
        android:orientation="vertical"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="fill_parent">

        <TextView
            android:id="@+id/Text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="22dip"
            android:textStyle="italic" />

        <TextView 
            android:id="@+id/Text2" 
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" 

            android:singleLine="true"
            android:ellipsize="marquee"/>

    </LinearLayout>
</LinearLayout>
Can'tCodeWon'tCode
  • 543
  • 1
  • 11
  • 36

1 Answers1

2

Try using the ARGB value for the background instead of using alpha. You can set it to 50% transparency by using #80FFFFFF.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:background="#80ffffff"
    android:padding="8dp">

See this post

Community
  • 1
  • 1
kevskree
  • 4,442
  • 3
  • 24
  • 32