Since on button, we can use android:drawableLeft to set the drawable on the left of a button. Is there way to get this drawable programmatically?
<Button android:id="@+id/detail_refresh_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/refresh"
android:gravity="center"
android:drawableLeft="@drawable/progress"
/>
Is there any way to get the drawable "progress" in Java code?
But Best way to do is :R. drawable. ic_delete); OR use the below code for Drawable left, top, right, bottom.
Simple. Just put the link in your TextView. Note: The most important property here is android:autoLink="all" . This allow you to link to urls, emails and phone numbers.
I think you want Button.getCompoundDrawables()[0]
Looking at : http://developer.android.com/reference/android/widget/Button.html
You can see that
myButton.setCompoundDrawablesWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable)
Should give you what your looking for.
Order: Left, top, right, and bottom
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With