將背景圖像添加到 XML Android 中的形狀 - Add a background image to shape in XML Android

問題:

How do you add a background image to a shape?如何將背景圖像添加到形狀? The code I tried below but no success:我在下面嘗試過但沒有成功的代碼:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
//here is where i need to set the image
<solid android:color="@drawable/button_image"/>
    <corners
     android:bottomRightRadius="5dp"
     android:bottomLeftRadius="5dp"
     android:topLeftRadius="5dp"
     android:topRightRadius="5dp"/>
 </shape>

解決方案:

參考一: https://en.stackoom.com/question/1Q7dY
參考二: https://stackoom.com/question/1Q7dY
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章