0
我想創建一個可繪製的,並將其用作我的按鈕的背景。 陰影的高度必須是18dip。看到圖片。Android按鈕,帶陰影的可繪製xml
我已經嘗試過這種方式,但它不工作:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false">
<layer-list>
<item android:gravity="bottom">
<bitmap android:src="@drawable/shadow9path"/> // This is a 9-path picture
</item>
<item android:gravity="bottom"
android:bottom="18dp">
<shape android:shape="rectangle">
<size android:height="@dimen/..." />
<corners android:radius="@dimen/..." />
<solid android:color="@color/..." />
</shape>
</item>
</layer-list>
</item>
...
</selector>
編輯: 陰影應該只在按鍵的底部。所以按鈕不應該被陰影所包圍。我需要一個複合視圖,它由按鈕和它下面的陰影組成。
這可能是你在找什麼http://stackoverflow.com/questions/15333529/how-to-提供陰影對按鈕 – Rishi
不幸的是,我不是在看霧。陰影應該只在按鈕的底部。我會更新這個問題。 – Alex
' //這是9個路徑的圖片'如果是** 9補丁**,爲什麼要使用'bitmap'?你應該使用'nine-patch':https://developer.android.com/guide/topics/resources/drawable-resource.html –