How To Set Background Image To Textview In Android?
i want to set background image to textview with its height and width.means if the textview size small than it set it small image if its size big than it draw large image to that te
Solution 1:
Try a 9-patch image. See here for details.
Solution 2:
maybe a xml drawable is helpful, depends to waht kind of image you want to load, store the following xml in your drawable folder and declare the cml as background for your textview
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_pressed="true"><shape><solidandroid:color="#ef4444"/><strokeandroid:width="1dp"android:color="#992f2f"/><cornersandroid:radius="4dp"/><paddingandroid:left="4dp"android:top="4dp"android:right="4dp"android:bottom="4dp"/></shape></item><item><shape><gradientandroid:startColor="#ef4444"android:endColor="#992f2f"android:angle="270"/><strokeandroid:width="1dp"android:color="#992f2f"/><cornersandroid:radius="4dp"/><paddingandroid:left="4dp"android:top="4dp"android:right="4dp"android:bottom="4dp"/></shape></item>
Post a Comment for "How To Set Background Image To Textview In Android?"