Android pushbutton button and ImageButton

Source: Internet
Author: User

Button--Buttons
ImageButton--Picture button
button and ImageButton features
1. Common features
Can be used as a button to generate click events
2. Different points:
(1) Button has the Text property, ImageButton has no
(2) ImageButton has the SRC attribute, button has no
3. Create a noticeable click effect

Achieve the effect of button and ImageButton
Note: We generally do not write the Android:text information directly but in the Res/values/strings.xml file
Add Button_name to String.xml:

<name= "Button_name"> login </string> 

The button references the value of Button_name through @string/button_name:

< Button         Android:id = "@+id/button1"         android:layout_width= "Match_parent"        android:layout_height= "Wrap_ Content "        android:text=" @string/button_name "/>

ImageButton:

< ImageButton         Android:id = "@+id/imagebutton1"         android:layout_width= "Match_parent"        android:layout_height= "Wrap_ Content "        android:src=" @drawable/ic_launcher "/>
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"    >    <ButtonAndroid:id= "@+id/button1"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "@string/button_name" />    <ImageButtonAndroid:id= "@+id/imagebutton1"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:src= "@drawable/ic_launcher" /></LinearLayout>
Fragment_main.xml
<?XML version= "1.0" encoding= "Utf-8"?><Resources><StringName= "App_name">buttonimagebutton</String><StringName= "Hello_world">hello world!</string> <string name= " Action_settings ">settings</string> <name= "Button_name" > login </string< Span style= "color: #0000ff;" >></resources                 
Strings.xml

Android pushbutton button and ImageButton

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.