1. One button control
1. Inheritance diagram
- Button is a subclass of TextView
2. Common attributes
Attributes |
meaning |
text |
text content |
textSize |
Text font size, unit: sp |
textColor |
Text color, #ff0000 - red |
background |
Background color or background image |
layout_height |
Height, unit: dp (wrap_content, match_parent) |
layout_weight |
Width, unit: dp (wrap_content, match_parent) |
onClick |
Click event (used to bind event handling methods) |
2. Image view
1. Inheritance diagram
- ImageView is a subclass of View
2. Common attributes
Attributes |
meaning |
layout_height |
Height, unit: dp (wrap_content, match_parent) |
layout_weight |
Width, unit: dp (wrap_content, match_parent) |
src |
Source (used to set the image source) |
background |
Background (used to set the background image) |
scaleType |
Scaling type (fitXY) |
tint |
mask |
3. Image button
1. Inheritance diagram
- ImageButton is a subclass of ImageView
2. Common attributes
Attributes |
meaning |
layout_height |
Height, unit: dp (wrap_content, match_parent) |
layout_weight |
Width, unit: dp (wrap_content, match_parent) |
src |
Source (used to set the image source) |
background |
Background (used to set the background image) |
4. Zoom in and out of images via buttons
1. Create an Android application
- Create an Android app via
Empty Activity
ZoomlamgeByButton
- Click the [finish] button
2. Prepare picture materials
- Add three pictures to the
drawable
file
3. String resource file
- String resource file -
string.xml
<resources>
<string name="app_name">通过按钮缩放图片</string>
<string name=