How to draw lines in Android Edit Text?

本小妞迷上赌 提交于 2019-12-23 15:34:39

问题


I am trying to build a notepad application. I want to have lines in the Edit Text view of my application which is a multi line Edit Text. Please let me know how to do this. Thank you for your time and advice.


回答1:


check this out.notepad




回答2:


I think you are best of just showing a background, not 'drawing lines'. Use the default background a View has:

http://developer.android.com/reference/android/view/View.html#setBackgroundResource(int)




回答3:


Since the size of the notepad will vary based upon the size of the phone's screen, a good option would be to create a canvas with a specified size and draw a line horizontally down the canvas in a constant interval. Then convert the canvas to a drawable and set the backgrounddrawable of the editText to the drawable.




回答4:


u can have this code in yr xml folder in res

    <?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
    <stroke android:width="1dp" android:color="#FF000000"
            />
            <padding android:bottom="20dip" />
</shape>

and include it in setBackgroundResource()



来源:https://stackoverflow.com/questions/6760124/how-to-draw-lines-in-android-edit-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!