简体   繁体   中英

android: how to change the opacity and color gradient of just the background of a text view

I need to programatically change the trasparency and color gradient gradually. Let's say I have a textview with background #FF0000FF (solid blue, no transparency) and i need it to change gradually to something that looks like #CC000000 (black background with 80% opacity). Let's say I also have a variable i that gradually goes from 0 to 100, how can I make #FF0000FF transform to #CC000000 along with it?

check this link for Setting the transparent background color gradient

try this code

   <TextView
                            android:id="@+id/txtView"
                            android:layout_width="58dp"
                            android:layout_height="58dp"
                            android:gravity="center"
                            android:textColor="@color/white_font"
                            android:textSize="20sp"
                            android:background="#99000000"
                            android:textStyle="bold" />

Hope this helps...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM