Android2.2 API Chinese Document Series (7) -- imagebutton

Source: Internet
Author: User

Preface

Article 7 The imagebutton translation was completed independently with the help of translation tools, and added some understanding or even a limited level. please correct me. More translators are welcome to participate in the Chinese translation operation of Android APIs! My mailbox over140@gmail.com.

 

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog: http://www.cnblogs.com

Farmer's uncle: http://www.cnblogs.com/over140/

 

 

Body

I. Structure

Java. Lang. Object
Android. View. View
Android. widget. imageview
Android. widget. imagebutton

Known direct subclass:

Zoombutton

 

Ii. Category summary

Display an image button that can be clicked by users. By default, imagebutton looks like a normal button and changes the background color in different States (such as pressing. The image of the button can be specified through the Android: src attribute of the <imagebutton> XML element or the setimageresource (INT) method.

To delete the background of a button, you can define your own background image or set the background to transparent. (Note: See

Source image and image button. By default, the background of the button is displayed around the image. The selected background is yellow)

To indicate different button states (Focus, selection, etc.), you can define different images for various States. For example, define a blue image as the default image, a yellow image as the image displayed when the current focal point is obtained, and a yellow image as the image displayed when the button is pressed. This can be done in a simple way-the XML "selector." configuration is as follows:

Save the above XMLres/drawable/Folder (Note: The file name is case sensitive !), Set the file name as a parameter to the Android: src attribute of imagebutton (Note: for example, the XML file name is myselector. in XML format, set it to "@ drawable/myselector" and set Android: background, but the effect is not the same ). Android will automatically search for the corresponding image in XML for Display Based on the button status change.

<Item> the order of elements is very important, because it is used to determine whether it is applicable to the current button status, which is why the specified image in the normal (default) status is placed at the end, it will only be used after both pressed and focused fail to judge. (Note: for example, when a button is pressed, the focus is obtained at the same time, but the focus is not necessarily pressed. Therefore, we will search for the focus in order. If the focus is found properly, we will not look down. If the button is clicked, the first one will be selected and will not be found later .)

See form stuff tutorial.

 

 

Iii. Methods inherited from parent classes

Public void setalpha (INT alpha)

Set the transparency of the imagebutton image (not the background image ). Effect

Parameters

Alpha transparency value 0 ~ 255, 0 is completely transparent, and is completely opaque

 

4. Download

PDF: http://download.csdn.net/source/2707338

 

V. Series

Android2.2 API Chinese Document Series (1) -- textview

Android2.2 API Chinese Document Series (2) -- edittext

Android2.2 API Chinese Document Series (3) -- accessibilityservice

Android2.2 API Chinese Document Series (4) -- manifest

Android2.2 API Chinese Document Series (5) -- View

Android2.2 API Chinese Document Series (6) -- imageview

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.