android實(shí)現(xiàn)背景平鋪的三種方法
方法1: 系統(tǒng)api實(shí)現(xiàn)
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pic);
//bitmap = Bitmap.createBitmap(100, 20, Config.ARGB_8888);
BitmapDrawable drawable = new BitmapDrawable(bitmap);
drawable.setTileModeXY(TileMode.REPEAT , TileMode.REPEAT );
drawable.setDither(true);
view.setBackgroundDrawable(drawable);
方法2: XML實(shí)現(xiàn)
xml路徑:res/drawable/bg.xml
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/img"
android:tileMode="repeat" />
方法3: 自定義繪制
public static Bitmap createRepeater(int width, Bitmap src){
int count = (width + src.getWidth() - 1) / src.getWidth();
Bitmap bitmap = Bitmap.createBitmap(width, src.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
for(int idx = 0; idx < count; ++ idx){
canvas.drawBitmap(src, idx * src.getWidth(), 0, null);
}
return bitmap;
}
- Android TextView設(shè)置背景色與邊框的方法詳解
- Android ListView的item背景色設(shè)置和item點(diǎn)擊無(wú)響應(yīng)的解決方法
- Android selector背景選擇器的使用詳解
- android 自定義ScrollView實(shí)現(xiàn)背景圖片伸縮的實(shí)現(xiàn)代碼及思路
- Android實(shí)現(xiàn)沉浸式通知欄通知欄背景顏色跟隨app導(dǎo)航欄背景顏色而改變
- Android編程實(shí)現(xiàn)popupwindow彈出后屏幕背景變成半透明效果
- android中實(shí)現(xiàn)背景圖片顏色漸變方法
- Android編程簡(jiǎn)單實(shí)現(xiàn)ImageView點(diǎn)擊時(shí)背景圖修改的方法
- Android中實(shí)現(xiàn)布局背景模糊化處理的方法
- Android漂浮背景效果的制作方法
相關(guān)文章
Android應(yīng)用中利用ViewPager實(shí)現(xiàn)多頁(yè)面滑動(dòng)切換效果示例
這篇文章主要介紹了Android應(yīng)用中利用ViewPager實(shí)現(xiàn)多頁(yè)面滑動(dòng)切換效果示例,配合了Fragment和PagerTabStrip,需要的朋友可以參考下2016-03-03
Android封裝MVP實(shí)現(xiàn)登錄注冊(cè)功能
這篇文章主要為大家詳細(xì)介紹了Android封裝MVP實(shí)現(xiàn)登錄注冊(cè)功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-11
android開(kāi)發(fā)PathEffect問(wèn)題處理
本文主要整理了關(guān)于android中PathEffect的問(wèn)題匯總以及處理方式,以及給大家做了關(guān)于PathEffect類的詳細(xì)解釋。2017-11-11
解決android studio卡頓,提升studio運(yùn)行速度的方法
這篇文章主要介紹了解決android studio卡頓,提升studio運(yùn)行速度的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03
Android Studio出現(xiàn)Failed to pull selection: open failed: Permi
本篇文章給大家分享了Android Studio中導(dǎo)出數(shù)據(jù)庫(kù)文件的方法以及出現(xiàn)Failed to pull selection: open failed: Permission denied的解決思路,有興趣的學(xué)習(xí)下。2018-05-05
Android 使用 Path 實(shí)現(xiàn)搜索動(dòng)態(tài)加載動(dòng)畫(huà)效果
這篇文章主要介紹了Android 使用 Path 實(shí)現(xiàn)搜索動(dòng)態(tài)加載動(dòng)畫(huà)效果,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),需要的朋友可以參考下2018-08-08
在Android開(kāi)發(fā)中使用自定義組合控件的例子
這篇文章主要介紹了在Android開(kāi)發(fā)中使用自定義組合控件的例子,作者根據(jù)例子總結(jié)到了實(shí)現(xiàn)父類的構(gòu)造方法等基本要點(diǎn),具有一定參考價(jià)值,需要的朋友可以參考下2016-02-02

