EditText background image fills parent

China☆狼群 提交于 2019-12-12 04:49:47

问题


I have EditText view like this:

<EditText 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="none"
    android:background="@drawable/writting_field"
    android:text="@string/test" />

But it stretches and fills parent. What is the problem?


回答1:


The problem may be Image size will be bigger enough so it occupying like FILL_PARENT. To get override this , use 9Patch images. So that it takes as much size as of the Text.




回答2:


If image size is same or bigger than parent it will automatically takes that much size , to take it fixed height width either you have to give it fixed height width in dp or try with ems option in edittext .



来源:https://stackoverflow.com/questions/17315901/edittext-background-image-fills-parent

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