澄迈住房和城乡建设局网站,下载app赚钱的平台,从化公司网站建设,祝贺网站改版目录 第一章 认识Android第二章 Android常见界面布局第三章 Android常用基本控件第四章 Android 高级控件第五章 Android菜单和对话框 第一章 认识Android
1. Android 界面设计被称为______。 答案#xff1a;布局 2. Android中常见的布局包括______、______ 、______ 、____… 目录 第一章 认识Android第二章 Android常见界面布局第三章 Android常用基本控件第四章 Android 高级控件第五章 Android菜单和对话框 第一章 认识Android
1. Android 界面设计被称为______。 答案布局 2. Android中常见的布局包括______、______ 、______ 、______ 、______ 五种。
相对布局RelativeLayout线性布局LinearLayout表格布局TableLayout网格布局GirdLLayout帧布局FrameLayout。
3. 什么是dppxsp
dp设备独立像素px像素sp放大像素
必考Android应用程序结构
src存放程序源代码gen系统自动生成无需手动修改。最重要的就是R.java文件保存了程序中断用到的所有控件和资源的ID。assets存放不进行编译和加工的原生文件这里的资源文件不会再 R.java 自动生成 ID。drawable-hdpi存放高分辨率图片。drawable-ldpi存放低分辨率图片。drawable-mdpi存放中分辨率图片。drawable-xhdpi存放超高分辨率图片。layout项目的布局文件就是应用程序界面的XML文件。menu菜单文件同样为XML格式在此可以为应用程序添加菜单。values该目录存放的XML文件定义了各种格式的键值对AndroidManifest.xml这是程序的清单文件。应用程序的所有组件都需要早该文件中进行注册否则程序无法识别不能使用。
第二章 Android常见界面布局
4. 相对布局分为______ 、______ 两种。
相对父容器布局相对控件布局
5.相对父容器布局的使用。在相对布局中添加一个Button在父容器中水平居中Button顶端与父容器上边框对齐Button上边缘距父容器上边缘64dp
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context${relativePackage}.${activityClass} !-- Button控件margin距离 alignParentTop对齐顶部centerHorizontal中心水平--Buttonandroid:id id/button1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentToptrueandroid:layout_centerHorizontaltrueandroid:layout_marginTop 64dpandroid:textstring/button1/
/RelativeLayout6. 相对控件布局的使用。添加一个Button2位于Button1右下方并且设置Buttton2上边缘距Button1 38dp。
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent Buttonandroid:idid/button1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentToptrueandroid:layout_centerHorizontaltrueandroid:layout_marginTop64dpandroid:textstring/button1 /Buttonandroid:idid/button2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_belowid/button1android:layout_marginTop38dpandroid:layout_toRightOfid/button1android:textstring/button2 //RelativeLayout
7. 线性布局可以分为______ 、 ______ 两种。
水平线性布局垂直线性布局
8. 水平线性布局的使用 LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent android:orientation horizontal/LinearLayout 9.垂直线性布局的使用 LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent android:orientationvertical//修改布局-当前为垂直Buttonandroid:idid/button1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textstring/button1 /Buttonandroid:idid/button2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textstring/button2 //LinearLayout第三章 Android常用基本控件
10. Android常用基本控件有______ 、 ______ 、 ______ 、 ______ 、 ______ 、 ______ 。
TextView文本框EditText编辑框Button按钮CheckBox多选按钮RadioButton单选按钮
11. 在布局文件中声明的控件只负责界面显示。如果要想使用控件实现某些具体功能就需要在Activety中编辑代码实现。实现过程如下
使用xxx来加载布局文件使用xxx获取控件引用使用这个引用对控件进行操作
12. 文本类控件主要用于在界面中显示文本 包含______ 、______两种。
TextViewEditView
13. Button类控件主要包括______ 、 ______ 、 ______ 、 ______ 、 ______ 五种。
ButtonImageButtonToggleButtonRadioButtonCheckBox
14. 为Button注册监听的两种办法
逻辑代码中编写OnClick方法布局代码中绑定匿名监听器并重写click方法
layout 布局代码
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent Button android:idid/button1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textstring/button1/Buttonandroid:idid/button2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_marginTop60dpandroid:onClickclickandroid:textstring/button2 //RelativeLayout逻辑代码
package com.example.button;import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class MainActivity extends Activity {Button button1,button2;Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button1 (Button)findViewById(R.id.button1);button2 (Button)findViewById(R.id.button2);button1 .setOnClickListener(new OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stubsetTitle(Button1注册成功);}});}public void click(View v) { setTitle(Button2注册成功);} }15. ToggleButton的使用
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent ToggleButtonandroid:idid/toggleButton1android:layout_width1500dpandroid:layout_height80dpandroid:layout_alignParentLefttrueandroid:layout_alignParentToptrue android:textOn开 android:textOff关//RelativeLayout16. RadioButton的使用选择坐飞机还是坐轮船 布局代码如下
LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:idid/LinearLayout1android:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationvertical TextView android:idid/tv1android:layout_widthwrap_contentandroid:layout_heightwrap_content android:textSize30spandroid:text请选择: /RadioGroupandroid:idid/rg1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:orientationvertical RadioButtonandroid:idid/rb1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize30spandroid:text火车 /RadioButtonandroid:idid/rb2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize30spandroid:text飞机 //RadioGroupTextView android:idid/tv2android:layout_widthwrap_contentandroid:layout_heightwrap_content android:textSize30spandroid:text您选择的是 /
/LinearLayout关键逻辑代码
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {public void onCheckedChanged(RadioGroup group, int checkedId) {// TODO Auto-generated method stubif (checkedId R.id.rb1) {textView.setText(您选择的是 radioButton1.getText());}else {textView.setText(您选择的是 radioButton2.getText());}}
});17.时钟控件包括______和______前者______时钟只显示分和秒后者显示______时钟可精确到秒
AnalogClockDigitalClock模拟数字
第四章 Android 高级控件
18. 进度条有______ 、______ 、______ 、______ 四种。
LargeNormalSmallHorizontal
19. ProgressBar 的属性表
属性名称属性说明style设置进度条样式max进度条的最大进度值progress第一进度值secondaryProgress次要进度值
20. ProgressBar 的使用
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent ProgressBarandroid:idid/progressBar1style?android:attr/progressBarStyleHorizontalandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_alignParentRighttrueandroid:layout_alignParentToptrueandroid:layout_marginTop36dpandroid:max100android:progress75android:secondaryProgress50 /ProgressBarandroid:idid/progressBar2style?android:attr/progressBarStyleSmallandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_belowid/progressBar1android:layout_marginTop24dp /ProgressBarandroid:idid/progressBar3android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_belowid/progressBar2android:layout_marginTop76dp /ProgressBarandroid:idid/progressBar4style?android:attr/progressBarStyleLargeandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_belowid/progressBar3android:layout_marginTop62dp //RelativeLayout21. SeekBar的使用
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent SeekBarandroid:idid/seekBar1android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_alignParentToptrueandroid:layout_marginTop93dp android:thumbandroid:drawable/btn_star_big_on android:max100 android:progress25 /TextViewandroid:idid/textView1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_belowid/seekBar1android:layout_marginLeft40dp android:text当前进度值为25//RelativeLayout关键代码:
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {public void onStopTrackingTouch(SeekBar seekBar) {// TODO Auto-generated method stub}public void onStartTrackingTouch(SeekBar seekBar) {// TODO Auto-generated method stub}public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {// TODO Auto-generated method stubtextView.setText(褰撳墠杩涘害鍊硷細 progress);}});22. RatingBar的使用 布局代码如下
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent RatingBarandroid:idid/ratingBar1style?android:attr/ratingBarStyleandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentLefttrueandroid:layout_alignParentToptrueandroid:layout_marginTop14dp android:numStars5android:rating4.0android:stepSize0.5/TextViewandroid:idid/textView1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_belowid/ratingBar1 android:layout_marginTop20dpandroid:text受欢迎度4.0颗星//RelativeLayout
逻辑代码如下
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {public void onRatingChanged(RatingBar ratingBar, float rating,boolean fromUser) {// TODO Auto-generated method stubtextView.setText(受欢迎度为 rating 颗星);}});第五章 Android菜单和对话框
23. 菜单分为3类______ 、______ 和______ 。
选项菜单Options Menu上下文菜单Context Menu子菜单Submene
24. 对话框主要包括______ 、______ 、______ 、______ 、______ 、______ 等
普通对话框提示对话框单选和复选对话框列表对话框进度对话框日期与时间对话框
25. 提示对话框AlertDialog的使用 逻辑代码如下
package com.example.alertdialog;import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;public class AlertDialogActivity extends Activity {Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);AlertDialog.Builder buildernew AlertDialog.Builder(this);builder.setIcon(android.R.drawable.ic_dialog_info);builder.setTitle(AlertDialog);builder .setMessage(你确定删除吗);builder.setPositiveButton(确定, new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialog, int which) {setTitle(确定); } });builder.setNegativeButton(取消, new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {setTitle(取消); }});builder.show();}}26. 什么是Toast 略
27. Toast的使用必考
28. 开发Notification主要涉及哪三个类
Notification.Builder一般用于动态地设置 Notification 的一些属性即用 set 类设置NotificationManager主要负责将 Notification 在状态栏中显示和取消Notification主要用于设置 Notification 的相关属性。