android EditText's background

拜拜、爱过 提交于 2020-01-04 05:39:09

问题


I would like to set to my EditText background .

Hm ... I don't know even how to explain .... When there is a lot of text vertical scroll enables ... I need to 'scroll' the background when user scrolls the text (Now I have that when user scrolls the text background is fixed, so text became crossed by lines of background)

Have you any ideas?


回答1:


Create a drawable in xml like this for lines as mybackground.xml, where @drawable/divider will be your line image with the prefered space between lines

<bitmap android="http://schemas.android.com/apk/res/android" 
     android:src="@drawable/divider"  
     android:tileMode="repeat" 
     android:dither="true"
/> 

and set the following attributes in EditText control to adjust the

android:background="@drawable/mybackground"
android:lineSpacingExtra="Your Value" 
android:lineSpacingMultiplier="Your Value" 



回答2:


You might want to give lineSpacingExtra and lineSpacingMultiplier a try and then try to adjust the background image to it so it all fits as desired. Alternatively you can also try to play around with a 9-patch image and get it to repeat as desired but I'm not sure is this is going to work that way. Those are two options to try out maybe I can come up with more at a later point.

EDIT: It won't work with 9-patches.



来源:https://stackoverflow.com/questions/4176808/android-edittexts-background

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