Android的定制UI的EditText [英] android custom EditText UI

查看:129
本文介绍了Android的定制UI的EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想以自定义方式的默认的EditText被绘制在屏幕上,我有这个code

Hello I would like to customize the way the default EditText is drawn on the screen, I have this code

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

 <item android:state_pressed="true" >
<shape android:shape="rectangle">
    <solid
        android:color="#00ff00" />
    <stroke
        android:width="5dp"
        android:color="#ff0000"
        android:dashWidth="3dp"
        android:dashGap="2dp" />
</shape>
</item>

<item android:state_focused="true" >
<shape>
    <gradient
        android:endColor="#8dc73f"
        android:centerColor="#d4d4d4"
        android:startColor="#d4d4d4"
        android:centerX="0.5"
        android:centerY="0.5"
        android:angle="270" />
    <stroke
        android:width="1dp"
        color="#8dc73f" />
    <corners
        android:radius="6dp" />
    <padding
        android:left="10dp"
        android:top="10dp"
        android:right="10dp"
        android:bottom="10dp" />
</shape>
</item>
 <item>        
 <shape>
     <gradient
        android:endColor="#d4d4d4"
        android:centerColor="#d4d4d4"
        android:startColor="#d4d4d4"
        android:angle="270" />
     <stroke
        android:width="1dp"
        color="#00ff00" />
     <corners
        android:radius="7dp" />
   </shape>
   </item>
  </selector>

至极工作正常,但问题是,在聚焦状态我想申请的影响轮的EditText和注意里面,像Android的应用效果的默认,这是可能的,以及如何,因为我还没有找到一个解决方案,上述code只适用于在里面的EditText的效果。

wich works fine but the problem is that on the focused state I would like to apply the effect round of the EditText and note inside, like the default android effect is applied, is this possible and how because I haven't found a solution, the above code only applies the effect inside the EditText.

推荐答案

你检查出记事本样品?他们绘制文本的每一行之间的线的自定义文本编辑类:

Have you checked out the Notepad sample? They have a custom TextEdit class that draws a line between each row of text:

<一个href="http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NoteEditor.html" rel="nofollow">http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NoteEditor.html

您可以覆盖的OnDraw()同样的方式做你想要的?

Could you override onDraw() the same way to do what you're looking for?

这篇关于Android的定制UI的EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆