Search code examples
androidtransparencytransparenttextview

Android Transparent TextView?


Simply, how to make a TextView transparent? (Not full transparency)

I searched the docs and the StackNetwork and couldn't find it? I guess there is something like this.

Thanks.

UPDATE

This is the XML code:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:background="@drawable/background">

    <ImageView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/header"
    android:src="@drawable/logo1"
    />
    <ListView android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:paddingRight="5dp"
    android:scrollbarStyle="outsideOverlay"
    android:cacheColorHint="#00000000" />


    <TextView
    android:id="@+id/footer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="25sp"
    android:singleLine="true"
    android:background="#07000000"
    android:textColor="#FFFFFF"
    android:text="rrrrr" />

 </LinearLayout>

I want the footer TextView to be transparent so that the ListView items can be seen while scrolling


Solution

  • Please try this piece of code..

    <TextView 
       android:id="@+id/txtview1"
       android:layout_width="wrap_content" 
       android:background="@drawable/bg_task" 
       android:layout_height="wrap_content" 
       android:textSize="14sp" 
       android:singleLine="true"
       android:textColor="#FFFFFF" />
    

    Used background image as transparent so may be solved that.

    OR

    android:background="#07000000"
    

    OR

    Please try below ...

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:gravity="center_horizontal" android:orientation="vertical"
        android:background="@drawable/main_bg">
        <ImageView android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:id="@+id/header"
            android:src="@drawable/btn_complete" />
        <RelativeLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <ListView android:id="@+id/list" android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:layout_weight="1"
                android:paddingRight="5dp" android:scrollbarStyle="outsideOverlay"
                android:cacheColorHint="#00000000" />
            <TextView android:id="@+id/footer" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:textSize="25sp"
                android:singleLine="true" android:background="#07000000"
                android:textColor="#FFFFFF" android:text="rrrrr"
                android:layout_centerInParent="true"
                android:layout_alignParentBottom="true" />
        </RelativeLayout>
    </LinearLayout>