I know that in Android we can use function setCompoundDrawables(..) to add drawable.
My problem is that my EditText is multy-lines and i want to put drawable in EditText's top|left corner. But using at setCompoundDrawables() function, only give choice to put drawable in specific side.
Is it possibility at Android API to Do it?
Seems it's impossible to do it with only
EditText
/TextView
without anyside effect and additional views (I've provided the way at the end, but it needs more work with image and can be not applicable for every phone, because of different edit text backgorunds depending of manufature). The same question have been asked already many times: here and here for example.Per my understanding the easiest and fastests way might be not as suggested in above questions (by usage of
RelativeLayout
), but just usingFrameLayout
the following way (You'll have 2 views vs 3 view usingRelativeLayout
+ImageView
): Make your icon 9patch (using 9patch tool). E.g. you have the following icon initially:Then You can convert it to the following one:
Using the following xml:
Gives the following result (I've added multiple lines of text):
Moreover, it's even possible to comply the task with only
EditText
(but You might loose default EditText background which might not be good, however You can include it into your ning-patch image; but it will still be the same on all phones instead of native one).The following xml also works fine:
Give the following result (note that default frame for edit has disappeared):![single view appearance](https://i.stack.imgur.com/MTtf6.png)
Try this one :