【问题标题】:Button with distinct corners and an Image at centre具有不同角和中心图像的按钮
【发布时间】:2015-05-15 13:41:53
【问题描述】:

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

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

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

结果图像:

现在我需要一张类似于以下的图片:

我已经尝试了以下代码:(对不起..这是一个答案。但它没有反映在 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"   />

这将图像固定在中心。但是还有其他方法吗?

【问题讨论】:

  • 你能发布你得到的图片吗?
  • 确定@NikMyers ..等一下。
  • 哎呀..我明白了..它没有反映在 xml 中,而是反映在设备中..

标签: android xml button shape


【解决方案1】:

如果没有其他帮助,您可以使用 9-patch 图像。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-09
    • 2021-12-28
    • 1970-01-01
    • 2012-05-15
    • 1970-01-01
    • 2013-10-07
    相关资源
    最近更新 更多