Android imagebutton cannot display text

Source: Internet
Author: User

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, the text is written into the image, but this will increaseProgramAnd the hard coding method will affect the release of multiple languages.

 

Solution 2: the solution is very simple. Through analysis, we can see the layout of imagebutton. We can directly inherit it and add a textview. The alignment is on the right side to enable imagebutton to support displaying the right side of the text.

 

Third: a more concise and efficient method: Use the button and set the Android: drawableleft and other properties of the button. Example:

<Button
Android: Id = "@ + ID/button1"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: drawableleft = "@ drawable/icon"
Android: text = "button"
/>

Type 4: Layout multiple layers

<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>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.