我搜索了很多,但沒有找到任何東西。我想爲佈局創建背景,但不是用顏色或漸變填充它,而是要用紋理填充它並重復它。我試過這個,但沒有奏效。你能告訴我一個解決方案嗎?Android佈局背景xml紋理
card_texture.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/paper_texture"
android:tileMode="repeat"
/>
card_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color = "@android:color/transparent"/>
<stroke android:width="2dp"
android:color="@color/text_color"/>
<corners
android:radius="20dp"
/>
</shape>
card_background.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/card_texture" >
<corners
android:radius = "20dp"/>
</item>
<item android:drawable="@drawable/card_shape" />
</layer-list>
,這是我如何使用它在我的佈局android:background="@drawable/card_background"
我得到這樣的東西。但我想在角落的紋理(用紅色標出)是透明的,以適合黑色邊框
凡使用它?我有一個佈局,其中有'background =「@ drawable/theXML_that_I_have_written」',另外我需要圓角和筆劃 – user3199577
我以爲你想用一張圖片... –
我編輯了我的答案,使其更加普遍化,畢竟,它應該給你從這裏做出任何你想要的東西的基礎 - 背景現在沒有更多的祕密給你了! ;) –