我從服務器下載圖像並將其設置爲背景。但我需要爲該背景圖像分配重複圖像漸變,並且我需要在其上顯示一些文本。在背景圖像上重複圖像漸變
這是我的代碼,它用於從服務器下載圖像並將其設置爲背景。
Bitmap bitmap = DownloadImage(imageUrl);
BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
bitmapDrawable.setGravity(Gravity.BOTTOM|Gravity.RIGHT);
//Drawable d = new BitmapDrawable(bitmap);
myLinearLayout.setBackgroundDrawable(bitmapDrawable);
我創建了一個圖層列表,我需要在背景的頂部顯示。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:type="radial" android:gradientRadius="500"
android:startColor="#17568A"
android:endColor="#494C4F" />
</shape>
</item>
<item>
<bitmap
android:src="@drawable/gradient_dish"
android:tileMode="repeat" />
</item>
</layer-list>
但我已經分配服務器映像佈局背景,所以不能在後臺分配這個XML文件。
我有一個圖像「gradient_dish」,我想重複,並希望與背景圖像顯示。
我怎樣才能做到這一點?請給我提供一些參考或鏈接。
在此先感謝...
不能只需在代碼從'BitmapDrawable'獲取從web +層創建'LayerDrawable'從您發佈的xml drawable中使用它作爲背景? – Luksprog
你有這方面的任何參考代碼嗎? –
看看這個https://gist.github.com/luksprog/5696975 – Luksprog