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. 使用FabricJS的箭头形状
- 2. Android drawable xml:绘制箭头
- 3. iPhone:制作箭头形状的UIBarButtonItem
- 4. 9patch箭头形状的图片
- 5. 更改标记箭头的形状
- 6. 绘制导航箭头形状的CSS
- 7. 定制的div右箭头形状
- 8. 圆形箭头与CSS
- 9. CSS自定义形状箭头
- 10. R igraph包 - 改变箭头形状
- 11. 调整大小箭头形状
- 12. android:如何改变后退箭头形状?
- 13. 我要创建使用CSS的箭头形状 - 请看截图
- 14. Android的XML形状绘制
- 15. Powerpoint VBA:搜索一个字符箭头并用形状箭头代替
- 16. 谷歌条形图与差异箭头
- 17. 如何解决使用CSS创建此箭头形状IE9
- 18. 与箭头式的
- 19. Android XML形状样式
- 20. Android包含xml形状
- 21. CSS3箭头框状branch.com
- 22. 特殊按钮形状(稍微旋转箭头)
- 23. android创建使用xml形状的弧形矩形
- 24. Android弹出箭头
- 25. SVG动画图形箭头
- 26. OpenGL正方形和箭头
- 27. 制作具有响应宽度的箭头形状,只有CSS
- 28. 试图用wpf创建一个箭头的形状?
- 29. Visio:在形状交叉处强制箭头的方法?
- 30. 如何设置与背景微调箭头下拉箭头?
如果背景是动态布局,则显示其白色通道[![enter image description here](http://i.stack.imgur.com/FKtR1.png)](http://i.stack。 imgur.com/FKtR1.png) – 2016-08-01 10:32:13