《Android应用讲义程序开发》用户界面开发

合集下载

第5章 用户界面开发

第5章 用户界面开发

Android应用程序的人机交互界面由很多Android控件 组成,下面我们就要来讲一讲一些我们经常需要用到的部
分控件了,使用功能最适合的界面控件是界面开发的关键,
所以我们要清楚的了解各个控件的共同点以及不同点,以 便能在需要的时候信手拈来。
2015/9/1
14
TextView和EditText
TextView(文本框)和EditText(编辑框)两者的属性基 本上是相同的。 TextView 用于在屏幕上显示文本,不能即 时 输 入 , EditText 用 于 在 屏 幕 上 显 示 可 编 辑 的 文 本 框 。 EditText是TextView类的子类。
。
2015/9/1
6
线性布局
LinearLayout线性布局是程序开发中最常用的 一种布局方式,水平线性布局和垂直线性两种。
XML属性 Android: orientation Android:gravity
相关方法 SetOrientati on(int) setGravity(i nt)
说 明 设置布局内组件的排列方式,可以设置为horizontal(水平排列) 、vertical(垂直排列、默认值)两个值的其中之一 设置布局内组件的对齐方式,可选值包括top、bottom、left、 right、center_vertical、fill_vertical、center_horizonal、 fill_horizontal、center、fill、clip_vertical和clip_horizontal.这些属 性值可以同时指定,各属性之间用竖线隔开。如要指定组件靠左 下角对齐,可以用left|botton
5.3 界面布局
在Android中,每个组件在窗体中都有具体的

Android系列课程III(Android移动开发)多用户界面设计

Android系列课程III(Android移动开发)多用户界面设计
3
Intent(译为意图)提供了不同Activity(活动界面)间数据交换的方法,被视 为Activity之间的纽带,它所传递的信息主要是动作(Action)和数据(data), 即要执行的动作和要操作的数据,动作使用Android系统预定义的常量表示,例如, ACTION_MAIN、ACTION_VIEW和ACTION_EDIT等;数据使用URI(统一资源标识符) 表示。借助Intent对象,调用方法startActivity可启动一个新的界面;调用方法 startService或bindService可与服务(没有用户界面的应用程序)通信;调用 方法sendBroadcast与所有广播接收器通信。此外,Intent 还具有category(分 类)、type(类型)、component(组件)和extras(附加信息)等属性,其中, category为动作提供分类信息;type用于显式指定MIME(多用途网络邮件扩展) 类型;component显式指定Intent使用的组件类;extras是一个Bundle对象,包 括附加的数据信息。
5
为了介绍隐式Intent的使用方法,下面以“记事本”应用程序的
1 <mAanndifreosidt Mxmanlnifse:satn.xdmrol为id=例"h说tt明p:,//s该ch文e件ma内s.容an如d下ro所id.示com/apk/res/android"
2
package="com.android.notepad">
24
<data
android:mimeType="vnd.android.cursor.item/vnd.google.note" />

04Android用户界面设计精品PPT课件

04Android用户界面设计精品PPT课件
Button、 ImageView 等 各个组件按线性 布局垂直摆放
线性布局 LinearLayout
UI:LinearLayout
线性布局 LinearLayout 方向:android:orientation="vertical " android:orientation="horizontal " 对齐:android:gravity="top " (bottom/left/right) 大小:android:layout_width="wrap_content " android:layout_width="fill_parent "
UI:布局管理 Layout
Layout:组件在 Activity 中的呈现方式即为“布局” 布局中需要描述组件的大小、间距、对齐方式等
Layout 的创建: 首先将需要呈现的组件在 xml 配置文件中进行声明 然后在程序中通过 setContentView(View) 方法 将视图呈现在 Activity中 最后通过 findViewById(Id) 方法获得各组件实 例
Google Android
智能手机应用开发
based on android 2011.5
内容包括:
1、Android 平台概述 2、搭建 Android 开发环境 3、第一个 Android 应用程序 4、Android 用户界面设计 5、Activity、Intent、Service、 Broadcast Receiver 6、Android 中的数据存取 7、Android 的多媒体应用 8、应用实例:a、b、c、d
UI:AbsoluteLayout

第5章Android用户界面 PPT

第5章Android用户界面 PPT

4.
android:text="Button01" >
5.
</Button>
6.
<ImageButton android:id="+id/ImageButton01"
7.
android:layout_width="wrap_content"
8.
android:layout_height="wrap_content">
1. Button button = (Button)findViewById(R、id、Button01); 2. ImageButton imageButton =
(ImageButton)findViewById(R、id、ImageButton01); 3. button、setText("Button按钮"); 4. imageButton、setImageResource(R、drawable、
3.
textView、setText("用户名:");
4.
editText、setText("Rajan");
第1行代码得findViewById()函数能够通过ID引用界面上得任何 控件,只要该控件在XML文件中定义过ID即可
第3行代码得setText()函数用来设置TextView所显示得内容
TextViewDemo、java文件中代码得修改
1.
TextView textView = (TextView)findViewById(R、id、
TextView01);
2.
EditText editText = (EditText)findViewById(R、id、EditText01);

第五章 Android用户界面

第五章  Android用户界面

颜色的表示
3、使用XML资源文件来表示颜色。这是一个扩展性比较好的方式,便于 今后可以方便的修改颜色值。 <?xml version=”1.0” encoding=”utf-8”> <resources> <color name=”mycolor”>#7fff00ff</color> </resources> int color = getResources().getColor(R.color.mycolor); getResources()方法返回当前活动Activity的ResourceManager 类实例。 @color/mycolor
It is possible to retrieve the location of a view by invoking the methods getLeft() and getTop(). The former returns the left, or X, coordinate of the rectangle representing the view. The latter returns the top, or Y, coordinate of the rectangle representing the view. These methods both return the location of the view relative to its parent. For instance, when getLeft() returns 20, that means the view is located 20 pixels to the right of the left edge of its direct parent.

第3讲:用户界面(I)

第3讲:用户界面(I)
• 绝对布局需要通过指定x、y坐标来控制每一个控件的位置,放入该布 局的组件需要通过android:layout_x和android:layout_y两个属性指定其 准确的坐标值,并显示在屏幕上。
3.3 布局的类型
• 3.3.6 绝对布局 (AbsoluteLayout)
绝对布局多用于游戏开发中,由于多分辨率 兼容麻烦,绝对布局在Android1.5后被 Google弃用,因此应用开发一般情况下不推
• 网格布局用一组无限细的直线将绘图区域分成行、列和单元,并指定 控件的显示区域和控件在该区域的显示方式。
3.3 布局的类型
• 脚下留心:
• 由于GridLayout是Android4.0之后有的新功能,如果要在项目中使用这 种布局,需要把SDK的最低版本指定为Android4.0(API14)以上。
• Android程序开发最重要的一个环节就是界面处理,界面的美观度直 接影响用户的第一印象,因此,开发一个整齐、美观的界面是至关 重要的。
3.1 UI概述
• Android应用的界面是由View和ViewGroup对象构建而成的。View类是 Android系统平台上用户界面表示的基本单元,View的一些子类被统称为 Widgets(工具),它们提供了诸如文本输入框和按钮之类的UI对象的完 整实现。
件,该文件位于项目的“res/layout”目录中。
3.3 布局的类型
Android中 有几种布局?
3.3 布局的类型
• Android中的布局如下:
• LinearLayout • RelativeLayout • TableLayout • GridLayout • FrameLayout • AbsoluteLayout
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档