13
A
回答
20
你需要的是建立在項目的drawable-xxx
文件夾shape xml file
然後用這個形狀背景的按鈕。
這裏是被稱爲形狀文件arrow_shape.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Colored rectangle-->
<item>
<shape android:shape="rectangle">
<size
android:width="100dp"
android:height="40dp" />
<solid android:color="#5EB888" />
<corners android:radius="0dp"/>
</shape>
</item>
<!-- This rectangle for the top arrow edge -->
<!-- Its color should be the same as the layout's background -->
<item
android:top="-40dp"
android:bottom="65dp"
android:right="-30dp">
<rotate
android:fromDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
</shape>
</rotate>
</item>
<!-- This rectangle for the lower arrow edge -->
<!-- Its color should be the same as the layout's background -->
<item
android:top="65dp"
android:bottom="-40dp"
android:right="-30dp">
<rotate
android:fromDegrees="-45">
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
</shape>
</rotate>
</item>
</layer-list>
然後把它作爲按鈕的背景,例如
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/arrow_shape"/>
下面是截圖:
更多的信息Layer-List
你可以找到here。
編輯:
但請記住,我使用的某些值形狀的寬度和高度。如果您更改了那些,則可能需要更改top, bottom and right attributes
的值。因此,在這種情況下,請考慮在您的項目的values
目錄中使用不同的值。
相關問題
- 1. 繪製導航箭頭形狀的CSS
- 2. 更改標記箭頭的形狀
- 3. iPhone:製作箭頭形狀的UIBarButtonItem
- 4. 9patch箭頭形狀的圖片
- 5. 調整大小箭頭形狀
- 6. Android的XML形狀繪製
- 7. 與箭頭式的
- 8. 特殊按鈕形狀(稍微旋轉箭頭)
- 9. Android彈出箭頭
- 10. SVG動畫圖形箭頭
- 11. 如何設置與背景微調箭頭下拉箭頭?
- 12. 如何使用android圖形類繪製箭頭?
- 13. android形狀內的形狀
- 14. 將指尖滑塊更改爲箭頭形狀
- 15. 在UINavigationController上創建後部箭頭形狀leftBarButtonItem
- 16. 將箭頭形狀連接到字符串
- 17. 與圓角XML形狀面膜佈局
- 18. Android - 如何正確繪製一個帶箭頭的箭頭?
- 19. JavaFX線/箭頭箭頭
- 20. 帶漸變的圓形箭頭
- 21. Android 9patch舒展箭頭?
- 22. Android Spinner箭頭更接近?
- 23. 與jQuery一起使用箭頭鍵scrollTo
- 24. 繪製箭頭與輪廓
- 25. 黑色箭頭狀態項目
- 26. 複合XML形狀
- 27. 使用CSS的箭頭
- 28. 使用箭頭鍵的
- 29. 缺少/更換箭頭字形
- 30. 用箭頭創建矩形DIV
如果背景是動態佈局,則顯示其白色通道[![enter image description here](http://i.stack.imgur.com/FKtR1.png)](http://i.stack。 imgur.com/FKtR1.png) – 2016-08-01 10:32:13