【问题标题】:Round shaped button getting distorted with length of text inside.圆形按钮因内部文本长度而变形。
【发布时间】:2014-01-23 15:14:49
【问题描述】:

我想要一个完美的圆形按钮。

我已经尝试使用以下代码使用形状。 但是我面临的问题是,当视图中有两个文本时,它看起来几乎是一个圆圈,但是一旦视图中有一个和三个字符,它就看起来是椭圆形的。

形状代码

  <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="true">


       <corners android:bottomRightRadius="20dip"
        android:bottomLeftRadius="20dip"  
        android:topRightRadius="20dip"
        android:topLeftRadius="20dip"
        />


       </shape>

请检查图中数字 2 和 22 的近圆形按钮 我对所有按钮都使用了相同的代码(上面提到的)

【问题讨论】:

  • 你能在你使用这个形状的地方显示 xml 布局吗?谢谢。

标签: android android-xml android-button


【解决方案1】:

在您的布局文件(或代码)中,保持按钮的尺寸固定(宽度=高度=一些 dp)。
例如:

layout_width="48dp"
layout_height="48dp"

【讨论】:

    猜你喜欢
    • 2019-08-23
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    • 1970-01-01
    相关资源
    最近更新 更多