【问题标题】:How to set up only circle size(in xml)?如何仅设置圆圈大小(在 xml 中)?
【发布时间】:2017-09-03 14:18:35
【问题描述】:

我想设置圆圈大小,但我不想调整图层列表中其他元素的大小。 我有这个代码:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <shape android:shape="rectangle">
        <solid android:color="@color/drawer_color" />
    </shape>
</item>
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <gradient
            android:endColor="#1b2727"
            android:centerColor="#1a2a29"
            android:startColor="#154440"
            android:type="linear"
            android:angle="90"/>
        <size
            android:height="600dp"
            android:width="600dp" />
        <stroke
            android:width="3dip"
            android:color="@color/drawer_ring_color" />
    </shape>
</item>


</layer-list>

我发现了什么:

还有我想看的:

如何做到这一点? 谢谢!

【问题讨论】:

    标签: android xml user-interface shape


    【解决方案1】:

    不幸的是,这种方式不起作用,您的可绘制对象将采用您使用该可绘制对象的视图大小。

    【讨论】:

      【解决方案2】:

      尝试在您的代码中设置padding

      <item>
          <shape android:shape="rectangle">
              <solid android:color="@color/drawer_color" />
              <padding
                  android:left="10dp"
                  android:top="100dp"
                  android:right="10dp"
                  android:bottom="100dp" />
          </shape>
      </item>
      

      【讨论】:

        猜你喜欢
        • 2021-05-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-22
        • 2014-07-08
        相关资源
        最近更新 更多