带有明显角落的按钮和位于中心的图像

时间:2015-05-15 13:41:53

标签: android xml button shape

我需要一个左侧圆角和右侧平角的按钮。

此代码可以使用完整的圆角:

<corners
        android:bottomLeftRadius="25dp"
        android:bottomRightRadius="25dp"
        android:topLeftRadius="25dp"
        android:topRightRadius="25dp"/>

结果图片:

done

现在我需要一个类似于以下图像的图像:

enter image description here

我尝试了以下代码:(抱歉......这是一个答案。但它没有反映在Xml中)

<corners
        android:bottomLeftRadius="25dp"
        android:bottomRightRadius="25dp"
        android:topLeftRadius="0dp"
        android:topRightRadius="0dp"/>

但这不是正确的。

为了使图像居中,我尝试了以下代码:

<Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:background="@drawable/border2"
                android:layout_weight="0.5"
                android:layout_margin="10dp"
                android:paddingRight="50dp"
                android:paddingLeft="50dp"
                android:drawableRight="@drawable/facebook"   />

这修复了中心的图像。但还有其他方法吗?

1 个答案:

答案 0 :(得分:0)

如果没有其他帮助,您可以使用9补丁图片。