EditText background image fills parent

2019-08-28 01:22发布

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?

2条回答
淡お忘
2楼-- · 2019-08-28 01:51

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.

查看更多
别忘想泡老子
3楼-- · 2019-08-28 02:07

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 .

查看更多
登录 后发表回答