【问题标题】:How to make drawable by layer-list如何通过图层列表进行绘制
【发布时间】:2018-12-27 07:21:45
【问题描述】:

我想自定义编辑文本如下图

目前,我正在使用带有width = 1dp 的视图来欺骗这种情况。
实际上这是一种肮脏的方法,所以我想通过图层列表制作一个可绘制文件,然后添加到 EditText 的背景中。它看起来像:

______________ 

______________ 

另一方面,作为 Android Edit Text 属性,我们可以使用 drawableTopdrawableBottom 添加分隔符(只是一个 shape line )。

我的问题:
方法 1 -> 我无法创建顶部和底部为一条线的背景
方法 2 -> 我尝试使用 drawableTop 但它没有显示

【问题讨论】:

标签: android background android-drawable shapes layer-list


【解决方案1】:

试试这个

    <?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="#a8a8a8" />
        </shape>
      </item>
      <item android:top="2dp" android:bottom="2dp">
        <shape android:shape="rectangle">
         <solid android:color="#ffffff" />
        </shape>
      </item>
    </layer-list>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-19
    • 2021-07-24
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 2012-12-11
    • 2011-10-29
    • 1970-01-01
    相关资源
    最近更新 更多