compound-drawables

How to place Compound drawable on top left of Text View

余生长醉 提交于 2020-01-14 09:45:53
问题 We can set compound drawables for textview as below using drawableLeft or setCompundDrawables but using this its only possible to place the drawable on left / right / top / bottom.But i want to put drawables only at top-left and top-right of the Textview. How can i do that ? 回答1: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id

Set actual text padding in TextView with compound drawables

ぐ巨炮叔叔 提交于 2019-12-04 15:46:38
问题 I have a ListView populated with an ArrayAdapter . For items I use just a single TextView layout. I want some of the rows to have compound drawables set. Question: is there a way to set padding for the actual text that is contained in TextView so that the compound drawables don't get the padding too? Other solution would be to lock the width of text. Do I need to add ImageViews to my layout? Thanks in advance. 回答1: Quite simple android:drawablePadding="5dp" It will automatically use the

Set actual text padding in TextView with compound drawables

亡梦爱人 提交于 2019-12-03 09:46:40
I have a ListView populated with an ArrayAdapter . For items I use just a single TextView layout. I want some of the rows to have compound drawables set. Question: is there a way to set padding for the actual text that is contained in TextView so that the compound drawables don't get the padding too? Other solution would be to lock the width of text. Do I need to add ImageViews to my layout? Thanks in advance. Quite simple android:drawablePadding="5dp" It will automatically use the padding according to the direction Gio I'm posting this as an answer so that someone, who comes across this post

How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView

纵饮孤独 提交于 2019-11-26 14:10:16
Ran the new Lint tool against my code. It came up with a lot of good suggestions, but this one I cannot understand. This tag and its children can be replaced by one and a compound drawable Issue: Checks whether the current node can be replaced by a TextView using compound drawables. A LinearLayout which contains an ImageView and a TextView can be more efficiently handled as a compound drawable And here is my layout <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerInParent="true"> <ImageView android:id="

Is it possible to use VectorDrawable in Buttons and TextViews using android:DrawableRight?

最后都变了- 提交于 2019-11-26 05:53:16
问题 When I use VectorDrawable assets in a textview or imageview I get a runtime crash when using \"android:DrawableRight\" / \"android:DrawableEnd\" / \"android:DrawableStart\" / \"android:DrawableLeft\". The app will compile fine without any warnings. I am using Gradle 1.5 Support Library 23.2 (\'com.android.support:appcompat-v7:23.2.0\') What I have found though is that I can programmatically assign SVG\'s in Java without crashes like this. TextView tv = (TextView) findViewById(R.id.textView);

How can I shrink the drawable on a button?

此生再无相见时 提交于 2019-11-26 04:38:58
问题 how can I make the drawable on a button smaller? The icon is too big, actually higher than the button. This is the code I am using: <Button android:background=\"@drawable/red_button\" android:drawableLeft=\"@drawable/s_vit\" android:id=\"@+id/ButtonTest\" android:gravity=\"left|center_vertical\" android:text=\"S-SERIES CALCULATOR\" android:textColor=\"@android:color/white\" android:layout_height=\"wrap_content\" android:layout_width=\"wrap_content\" android:layout_marginLeft=\"25dp\" android

How do I use a compound drawable instead of a LinearLayout that contains an ImageView and a TextView

ε祈祈猫儿з 提交于 2019-11-26 04:07:40
问题 Ran the new Lint tool against my code. It came up with a lot of good suggestions, but this one I cannot understand. This tag and its children can be replaced by one and a compound drawable Issue: Checks whether the current node can be replaced by a TextView using compound drawables. A LinearLayout which contains an ImageView and a TextView can be more efficiently handled as a compound drawable And here is my layout <LinearLayout android:layout_width=\"wrap_content\" android:layout_height=\

Handling click events on a drawable within an EditText

倖福魔咒の 提交于 2019-11-26 00:39:36
问题 I have added an image right of the text in an EditText widget, using the following XML: <EditText android:id=\"@+id/txtsearch\" ... android:layout_gravity=\"center_vertical\" android:background=\"@layout/shape\" android:hint=\"Enter place,city,state\" android:drawableRight=\"@drawable/cross\" /> But I want to clear the EditText when the embedded image is clicked. How can I do this? 回答1: Actually you don't need to extend any class. Let's say I have an EditText editComment with a drawableRight