How can I shrink the drawable on a button?

I have found a very simple and effective XML solution that doesn’t require ImageButton Make a drawable file for your image as below and use it for android:drawableLeft <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:id=”@+id/half_overlay” android:drawable=”@drawable/myDrawable” android:width=”40dp” android:height=”40dp” /> </layer-list> You can set the image size with android:width and android:height properties. This way you could … Read more

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

it possible to use drawableRight etc for SVG assets ? Yes AppCompatTextView now supports app:drawableLeftCompat, app:drawableTopCompat, app:drawableRightCompat, app:drawableBottomCompat, app:drawableStartCompat and app:drawableEndCompat compound drawables, supporting backported drawable types such as VectorDrawableCompat. Include this in your gradle file implementation ‘androidx.appcompat:appcompat:1.1.0-alpha01’ In your text view you can use app:drawableLeftCompat app:drawableStartCompat If you have problems while using app:drawableLeftCompat, app:drawableStartCompat … Read more

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

TextView comes with 4 compound drawables, one for each of left, top, right and bottom. In your case, you do not need the LinearLayout and ImageView at all. Just add android:drawableLeft=”@drawable/up_count_big” to your TextView. See TextView#setCompoundDrawablesWithIntrinsicBounds for more info.

Handling click events on a drawable within an EditText

Actually you don’t need to extend any class. Let’s say I have an EditText editComment with a drawableRight editComment.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { final int DRAWABLE_LEFT = 0; final int DRAWABLE_TOP = 1; final int DRAWABLE_RIGHT = 2; final int DRAWABLE_BOTTOM = 3; if(event.getAction() == MotionEvent.ACTION_UP) { if(event.getRawX() >= … Read more