android - 如何使按钮指向右或左?

标签 android xml button android-button rounded-corners

我希望在我的应用程序中使用这种形状的按钮,指向右侧或左侧。

按钮的两个角是圆形的,另一边是三角形的。

我能够使用 png 图像作为背景来完成此任务,但我更想知道如何在 xml 中完成此操作。

enter image description here

最佳答案

不确定具体的方法,但您始终可以将 topLeftbottomLeft 或 Right 的半径增加到最大值,得到半圆形尖端。 这就是我尝试做的事情

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:topLeftRadius="100dp"
android:topRightRadius="31dp"
android:bottomLeftRadius="100dp"
android:bottomRightRadius="31dp"
/>
<gradient
android:angle="45"
android:centerX="35%"
android:centerColor="#7995A8"
android:startColor="#E8E8E8"
android:endColor="#000000"
android:type="linear"
/>
<size
android:width="172dp"
android:height="60dp"
/>
<stroke
android:width="3dp"
android:color="#878787"
/>
</shape> 

This is how it looks..

关于android - 如何使按钮指向右或左?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38300396/

相关文章:

android - 交互协调 : onStop and onResume

android - 当我在手机(android 6.1 和 api 23)上运行我的应用程序时它崩溃了,但是当我在模拟器(android 7.0 和 api 24)上运行它时它不会崩溃

xml - 使用 XSLT 转换 XML 并保留 CDATA(在 Ruby 中)

xml - phobos 的 std.xml 的状态是什么

winforms - 按钮图像离按钮顶部太远;离按钮底部太近

android - 为 Galaxy S8/S8+ 指定的屏幕密度

Android ADB无需root即可访问应用程序数据库

本地图区域自动移动时,Android map v2 变得低质量

javascript - 如何根据按钮单击添加两个每行总和?

java - 如何在Java/Android中制作单独的按钮功能?