Many people have questions about ImageButton provided by Android. When a Drawable image is displayed, text is no longer displayed. There are three solutions:
First:That is, text is written into the image, but this will increase the size of the program, and the hard encoding method will affect the publishing of multi-language languages.
Second:The solution is very simple. Through analysis, we can see the layout of ImageButton. We can directly inherit the layout by adding a TextView and alignment to the right side to enable ImageButton to support displaying the right side of the text.
Third:More concise and efficient method: Use the Button and set the android: drawableLeft and other attributes of the Button. Example:Copy codeThe Code is as follows: <Button
Android: id = "@ + id/button1"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: drawableLeft = "@ drawable/icon"
Android: text = "button"
/>
Fourth:Multiple layers with LayoutCopy codeThe Code is as follows: <LinearLayout
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: orientation = "vertical"
Android: id = "@ + id/bt">
<ImageView
Android: id = "@ + id/ib"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: src = "@ drawable/ringlove"
Android: background = "#00000000"
/>
<TextView
Android: id = "@ + id/TV"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/cs"
Android: paddingLeft = "20px"
/>
</LinearLayout>