日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

android setAlpha 与 getBackground().setAlpha

發(fā)布時(shí)間:2023/11/27 生活经验 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android setAlpha 与 getBackground().setAlpha 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

setAlpha() 里面的取值為0f-1f 改變的是view的顏色以及view里面內(nèi)容的顏色,

setAlpha(0f) 整個(gè)view 變?yōu)榱送该?setAlpha(1f) 這個(gè)顯示原始的view?

getBackground().setAlpha() 里面的取值為 0-255 改變的背景顏色的變化

getBackground().setAlpha(0) 背景變?yōu)橥该?,getBackground().setAlpha(255)背景色 為默認(rèn)的顏色

getBackground().setAlpha() 有時(shí)候使用的時(shí)候會(huì)改變其他控件的背景色也一起改變 這個(gè)時(shí)候需要

添加一個(gè)mutate 例如? getBackground().mutate().setAlpha(0); 這樣就不會(huì)影響到其他的布局了

寫幾個(gè)對比

寫幾個(gè)txtview 設(shè)置背景色如下

?

使用setAlpha();

findViewById(R.id.txt).setAlpha(0f);
findViewById(R.id.txt1).setAlpha(0.3f);
findViewById(R.id.txt2).setAlpha(0.5f);
findViewById(R.id.txt3).setAlpha(0.8f);
findViewById(R.id.txt4).setAlpha(1f);

效果圖下

可以看到第一個(gè)text 完全變?yōu)橥该髁?/p>

使用getBackground().mutate().setAlpha(0)

       findViewById(R.id.txt).getBackground().mutate().setAlpha(0);findViewById(R.id.txt1).getBackground().mutate().setAlpha(100);findViewById(R.id.txt2).getBackground().mutate().setAlpha(150);findViewById(R.id.txt3).getBackground().mutate().setAlpha(200);findViewById(R.id.txt4).getBackground().mutate().setAlpha(230);

效果圖如下

可以看的出只是改變了背景色,并沒有改變文字的顏色。。。。。

?

總結(jié)

以上是生活随笔為你收集整理的android setAlpha 与 getBackground().setAlpha的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。