版权声明:转载请邮件联系我([email protected]),以取得授权,谢谢! https://blog.csdn.net/yeshennet/article/details/82145131
最近做新项目,项目中有个地方需要在EditText的地步加一条背景线,还要随着选中变色。
在 stackoverflow 上没找到答案,我自己研究了一下,画了出来。
这个做一个小笔记
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<rotate android:fromDegrees="180" android:pivotX="50%" android:pivotY="75%" android:toDegrees="180">
<shape android:shape="line">
<stroke android:width="2dp" android:color="#FF00FFFF" />
<size android:width="1dp" android:height="2dp" />
</shape>
</rotate>
</item>
<item android:state_focused="false">
<rotate android:fromDegrees="180" android:pivotX="50%" android:pivotY="75%" android:toDegrees="180">
<shape android:shape="line">
<stroke android:width="2dp" android:color="#FF00FF00" />
<size android:width="1dp" android:height="2dp" />
</shape>
</rotate>
</item>
</selector>
方法就是先画一居中的横线,再在高度75%处进行中心旋转。
完~