user3450498
user3450498

Reputation: 267

Background image in TextView showing up transparent

I have a circle png that I put as a background image in a TextView. However, the image shows up transparent even when I tried setting the alpha level to "1". Is there something wrong I did in my XML code?

<TextView
            android:id="@+id/timeline_text_details_img"
            android:layout_width="55dp"
            android:layout_height="55dp"
            android:layout_gravity="center"
            android:layout_marginTop="25dp"
            android:background="@drawable/circle"
            android:gravity="center"
            android:textColor="#fff"
            android:textSize="14dp"
            android:alpha="1"
            android:textStyle="bold" />

The circle png I want needs to be thick white like how it originally is

enter image description here

but instead it looks like this when I run it

enter image description here

Upvotes: 1

Views: 42

Answers (1)

Muhammad Umar
Muhammad Umar

Reputation: 11782

You can simply create a shape circle.xml and place it in drawable.

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <stroke
        android:width="2dp"
        android:color="@android:color/white"
        />

    <solid
        android:color="#000000"/>

</shape>

You can change the color scheme as you like.

Upvotes: 2

Related Questions