造型的EditText视图形状绘制到类似于新的全息主题为Android< 3.0全息、视图、形状、类似

2023-09-12 03:58:04 作者:星有灵犀遇见你

我想创建一个形状绘制以模仿新的全息主题(安卓> = 3.0)在旧的Andr​​oid版本。

I want to create a shape drawable for that mimics the new holographic theme (Android >=3.0) on older Android versions.

这是很容易画一条线在底部用

It's quite easy to draw a line at the bottom with

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

      <!-- main color -->
      <item android:bottom="1.5dp">
          <shape >
              <solid android:color="@color/background" />
          </shape>
      </item>
  </layer-list>

但如何绘制左蜱边界和权利,在全息主题

But how to draw the tick boundaries left and right as in the holo theme

推荐答案

这是一个小黑客,但除非你找到更好的东西,这种方式应该是可行的。

It's a little hack, but unless you find something better, this way it should be possible.

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

  <!-- main color -->
  <item android:bottom="1.5dp"
      android:left="1.5dp"
      android:right="1.5dp">
      <shape >
          <solid android:color="@color/background" />
      </shape>
  </item>

  <!-- draw another block to cut-off the left and right bars -->
  <item android:bottom="15.0dp">
      <shape >
          <solid android:color="@color/background" />
      </shape>
  </item>
</layer-list>
 
精彩推荐
图片推荐