Get清风android实验3界面设计布局管理器.docx

上传人:b****7 文档编号:9460476 上传时间:2023-02-04 格式:DOCX 页数:11 大小:175.25KB
下载 相关 举报
Get清风android实验3界面设计布局管理器.docx_第1页
第1页 / 共11页
Get清风android实验3界面设计布局管理器.docx_第2页
第2页 / 共11页
Get清风android实验3界面设计布局管理器.docx_第3页
第3页 / 共11页
Get清风android实验3界面设计布局管理器.docx_第4页
第4页 / 共11页
Get清风android实验3界面设计布局管理器.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

Get清风android实验3界面设计布局管理器.docx

《Get清风android实验3界面设计布局管理器.docx》由会员分享,可在线阅读,更多相关《Get清风android实验3界面设计布局管理器.docx(11页珍藏版)》请在冰豆网上搜索。

Get清风android实验3界面设计布局管理器.docx

Get清风android实验3界面设计布局管理器

android实验3界面设计:

布局管理器

 

西安邮电大学

〔计算机学院〕

课内实验报告

实验名称:

界面设计:

布局管理器

 

专业:

网络工程

班级:

姓名:

学号:

指导教师:

日期:

2021年5月4日

 

一.实验目的

1.了解四种布局管理器的区别和各自特别的属性

2.掌握四种布局管理器的应用场合和用法

3.灵活使用四种布局文件管理器和嵌套实现各种复杂布局

4.掌握复用XML布局文件的方法

5.掌握代码控制UI界面的方法

二.实验环境

JDK的版本:

"1.8.0_40"

IDE:

eclipse

模拟器:

夜神模拟器

三.实验内容

设计的样式,完成Android应用UI的应用开发

四.实验过程及分析

1.用JAVA代码设置全屏

翻开工程src目录下的主Activity文件,在onCreate方法中的执行语句super.onCreate(savedInstanceState)之前,添加如下两句语句

requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏运营商图标、电量等

2.按照图1设计的样式,完成一个Android应用UI的开发

〔1〕添加代码

android=

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

orientation="vertical">

android:

id="@+id/imageView1"

android:

layout_width="350dp"

android:

layout_height="100dp"

android:

src="@drawable/ic_launcher4"/>

android:

layout_width="match_parent"

android:

layout_height="76dp"

android:

layout_marginTop="14dp"

android:

orientation="horizontal">

android:

layout_width="100dp"

android:

layout_height="100dp"

android:

src="@drawable/ic_launcher1"/>

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

gravity="center_vertical">

android:

layout_width="wrap_content"

android:

layout_height="wrap_content">

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="账号:

"/>

android:

id="@+id/userName"

android:

layout_width="120dp"

android:

layout_height="wrap_content"/>

android:

layout_width="wrap_content"

android:

layout_height="wrap_content">

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="密码:

"/>

android:

id="@+id/userPass"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

inputType="textPassword">

android:

layout_width="156dp"

android:

layout_height="28dp"

android:

layout_gravity="center"

android:

layout_marginBottom="10dp"

android:

layout_marginTop="20dp"

android:

background="#333"

android:

onClick="login"

android:

text="登录"

android:

textColor="#FFF"/>

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_marginLeft="20dp"

android:

text="记住密码"/>

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_marginLeft="20dp"

android:

text="自动登录"/>

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_marginLeft="20dp"

android:

text="接收产品推广"/>

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

layout_marginTop="12dp">

android:

layout_width="124dp"

android:

layout_height="34dp"

android:

layout_marginLeft="160dp"

android:

background="#333"

android:

onClick="forgetPass"

android:

text="忘记密码"

android:

textColor="#FFF"/>

android:

layout_width="124dp"

android:

layout_height="34dp"

android:

layout_marginLeft="30dp"

android:

background="#333"

android:

onClick="register"

android:

text="注册账号"

android:

textColor="#FFF"/>

android:

layout_width="match_parent"

android:

layout_height="63dp"

android:

orientation="vertical">

android:

id="@+id/loading"

android:

layout_width="match_parent"

android:

layout_height="wrap_content"/>

style="?

android:

attr/progressBarStyleSmall"

android:

layout_width="match_parent"

android:

layout_height="30dp"

android:

layout_marginBottom="10dp"/>

〔2〕查看布局效果

 

3.在主Activity文件中,添加用于登录的Login方法用于处理忘记密码的forgetPass方法、用于注册界面Register方法,

〔1〕在MainActivity类中添加登录、忘记密码、注册密码的时间监听程序

publicvoidlogin(Viewview){

if(check()){

StringBuildersb=newStringBuilder();

sb.append("登录成功!

"+"\n");

sb.append("用户名:

"+userName.getText().toString()+"\n");

sb.append("密码:

"+userPass.getText().toString()+"\n");

Toast.makeText(this,sb.toString(),Toast.LENGTH_LONG).show();

Intentintent=newIntent();//登录到ResultActivity页面

intent.setClass(this,ResultActivity.class);

intent.putExtra("info",sb.toString());

this.startActivity(intent);

}

}

//翻开忘记密码界面

publicvoidforgetPass(Viewview){

StringBuildersb=newStringBuilder();

Intentintent=newIntent();//忘记密码到PassActivity页面

intent.setClass(this,PassActivity.class);

intent.putExtra("info",sb.toString());

this.startActivity(intent);

}

//翻开注册界面

publicvoidregister(Viewview){

StringBuildersb=newStringBuilder();

Intentintent=newIntent();//注册到RegisterActivity页面

intent.setClass(this,RegisterActivity.class);

intent.putExtra("info",sb.toString());

this.startActivity(intent);

}

该类的布局如以下图:

〔2〕创立登录后的类ResultActivity,对于对于MainActivity传来的数据进行显示

 

protectedvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.activity_result);

TextViewresult=(TextView)findViewById(R.id.result);

result.setText("从前一个页面穿过来的内容如下:

\n\n"

+this.getIntent().getStringExtra("info"));

}

该类的布局如图:

〔3〕创立忘记密码的类ForgetPassActivity

publicvoidcomplete(Viewview){

//StringBuildersb=newStringBuilder();

Intentintent=newIntent();//忘记密码到MainActivity页面

intent.setClass(this,MainActivity.class);

//intent.putExtra("info",sb.toString());

this.startActivityForResult(intent,0x111);

}

该类的布局如图:

〔4〕创立注册密码的类RegisterActivity,编写事件处理程序

publicvoidregister(Viewview){

Intentintent=newIntent();//忘记密码到MainActivity页面

intent.setClass(this,MainActivity.class);

this.startActivityForResult(intent,0x111);

}

五.总结

1.实验过程中遇到的问题及解决方法;

问题:

在布局的嵌套过程中,不是顺利。

解决方法:

通过绘制草图进行详细分析,分析出类一种布局

2.对设计及调试过程的心得体会。

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1