Bes Sa
Bes Sa

Reputation: 93

Make button background transparent yet button text visible Android

I want to make my button transparent in my java application for Android but when I use

    android:background="@android:color/transparent"

It is also making the text on my button invisible and I would like to avoid that. Is there a way to make the text on my transparent button visible?

This is full code for my button:

 <Button
    android:id="@+id/Button01"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.01"
    android:onClick="scanName"
    android:orientation="center"
    android:background="@android:color/transparent"
    android:text="@string/tap to start scanning" />

Upvotes: 4

Views: 9814

Answers (3)

Joyal
Joyal

Reputation: 412

Try this, set the text color as your wish..Now it is red(#9a0a0a).

<Button
android:id="@+id/Button01"
android:layout_width="match_parent"
android:layout_height="wrap_content"   
android:textColor="#9a0a0a"
android:layout_weight="0.01"
android:onClick="scanName"   
android:orientation="center"
android:background="@android:color/transparent"
android:text="@string/tap to start scanning"  />

Upvotes: 1

gvmani
gvmani

Reputation: 1600

Did you try setting the android:textColor for your button ?

Upvotes: 7

Santosh Kathait
Santosh Kathait

Reputation: 1444

Use android:background="#0000"

Upvotes: 3

Related Questions