A CompoundDrawable is a TextView with an image and a text right? So if it's a combination of the two, how can you put the text in the center with respect to the image? Or how can you put the image in the center with respect to the text if the text is a bit smaller compared to the image? Or what if the image is smaller than the text? How could I cover these scenarios using XML
?
Here is an example of a CompoundDrawable:
<TextView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableTop="@drawable/image" android:text="@string/text" />
Add android:gravity="center"
to your TextView.
cool stuff with android:drawablePadding="-20dp" android:paddingLeft="20dp" <Button android:id="@+id/btn_pre" style="?android:buttonBarStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginRight="1dp" android:layout_weight="1" android:background="@color/bottom_tab" android:contentDescription="@string/image_view" android:drawableLeft="@drawable/prev" android:drawablePadding="-20dp" android:onClick="navigateStaticPages" android:paddingLeft="20dp" android:text="@string/pre" android:textColor="#000" android:textSize="@dimen/login_textSize" />
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