ImageVerifierCode 换一换
格式:DOCX , 页数:23 ,大小:204.48KB ,
资源ID:24650460      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/24650460.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Android开发教程笔记UI编程1.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Android开发教程笔记UI编程1.docx

1、Android开发教程笔记UI编程1Android 基础UI编程 1更改与显示文字标签TextView 标签的使用1导入TextView包import android.widget.TextView;2在mainActivity.java中声明一个TextViewprivate TextView mTextView01;3在main.xml中定义一个TextView 4利用findViewById()方法获取main.xml中的TextView mTextView01 = (TextView) findViewById(R.id.TextView01);5设置TextView标签内容 Stri

2、ng str_2 = 欢迎来到Android 的TextView 世界.; mTextView01.setText(str_2);6设置文本超级链接TextView android:id=+id/TextView02 android:layout_width=wrap_content android:layout_height=wrap_content android:autoLink=all android:text=请访问Android 开发者: android.graphics.Color实践-Color颜色变幻android.graphics.Color包含颜色值Color.BLACK

3、 Color.BLUE Color.CYAN Color.DKGRAY Color.GRAY Color.GREEN Color.LTGRAY Color.MAGENTA Color.RED Color.TRANSPARENT Color.WHITE Color.YELLOW 黑色蓝色青绿色灰黑色灰色绿色浅灰色红紫色红色透明白色黄色编程实现颜色变幻1新建工程2修改mainActivity.java文件,添加12个TextView对象变量,一个LinearLayout对象变量、一个WC整数变量、一个LinearLayout.LayoutParams变量。package zyf.ManyColor

4、ME;/*导入要使用的包*/import android.app.Activity;import android.graphics.Color;import android.os.Bundle;import android.widget.LinearLayout;import android.widget.TextView;public class ManyColorME extends Activity /* Called when the activity is first created. */ /* 定义使用的对象 */ private LinearLayout myLayout; p

5、rivate LinearLayout.LayoutParams layoutP; private int WC = LinearLayout.LayoutParams.WRAP_CONTENT; private TextView black_TV, blue_TV, cyan_TV, dkgray_TV, gray_TV, green_TV,ltgray_TV, magenta_TV, red_TV, transparent_TV, white_TV, yellow_TV; Override public void onCreate(Bundle savedInstanceState) su

6、per.onCreate(savedInstanceState); /* 实例化一个LinearLayout布局对象 */ myLayout = new LinearLayout(this); /* 设置LinearLayout的布局为垂直布局 */ myLayout.setOrientation(LinearLayout.VERTICAL); /* 设置LinearLayout布局背景图片 */ myLayout.setBackgroundResource(R.drawable.back); /* 加载主屏布局 */ setContentView(myLayout); /* 实例化一个Lin

7、earLayout布局参数,用来添加View */ layoutP = new LinearLayout.LayoutParams(WC, WC); /* 构造实例化TextView对象 */ constructTextView(); /* 把TextView添加到LinearLayout布局中 */ addTextView(); /* 设置TextView文本颜色 */ setTextViewColor(); /* 设置TextView文本内容 */ setTextViewText(); /* 设置TextView文本内容 */ public void setTextViewText() b

8、lack_TV.setText(黑色); blue_TV.setText(蓝色); cyan_TV.setText(青绿色); dkgray_TV.setText(灰黑色); gray_TV.setText(灰色); green_TV.setText(绿色); ltgray_TV.setText(浅灰色); magenta_TV.setText(红紫色); red_TV.setText(红色); transparent_TV.setText(透明); white_TV.setText(白色); yellow_TV.setText(黄色); /* 设置TextView文本颜色 */ public

9、 void setTextViewColor() black_TV.setTextColor(Color.BLACK); blue_TV.setTextColor(Color.BLUE); dkgray_TV.setTextColor(Color.DKGRAY); gray_TV.setTextColor(Color.GRAY); green_TV.setTextColor(Color.GREEN); ltgray_TV.setTextColor(Color.LTGRAY); magenta_TV.setTextColor(Color.MAGENTA); red_TV.setTextColor

10、(Color.RED); transparent_TV.setTextColor(Color.TRANSPARENT); white_TV.setTextColor(Color.WHITE); yellow_TV.setTextColor(Color.YELLOW); /* 构造实例化TextView对象 */ public void constructTextView() black_TV = new TextView(this); blue_TV = new TextView(this); cyan_TV = new TextView(this); dkgray_TV = new Text

11、View(this); gray_TV = new TextView(this); green_TV = new TextView(this); ltgray_TV = new TextView(this); magenta_TV = new TextView(this); red_TV = new TextView(this); transparent_TV = new TextView(this); white_TV = new TextView(this); yellow_TV = new TextView(this); /* 把TextView添加到LinearLayout布局中 */

12、 public void addTextView() myLayout.addView(black_TV, layoutP); myLayout.addView(blue_TV, layoutP); myLayout.addView(cyan_TV, layoutP); myLayout.addView(dkgray_TV, layoutP); myLayout.addView(gray_TV, layoutP); myLayout.addView(green_TV, layoutP); myLayout.addView(ltgray_TV, layoutP); myLayout.addVie

13、w(magenta_TV, layoutP); myLayout.addView(red_TV, layoutP); myLayout.addView(transparent_TV, layoutP); myLayout.addView(white_TV, layoutP); myLayout.addView(yellow_TV, layoutP); 3结果android.graphics.Typeface实践字体风格Typeface种类int Style类型BOLDBOLD_ITALICITALICNORMAL粗体粗斜体斜体普通字体Typeface类型DEFAULTDEFAULT_BOLDM

14、ONOSPACESANS_SERIFSERIF默认字体默认粗体单间隔字体无衬线字体衬线字体Typeface.create(Typeface family,int style)创建一个混合型新的字体:有4*5中搭配Typeface.setTypeface (Typeface tf, int style) 设置一个混合型字体:有4*5中搭配Typeface.setTypeface(Typeface tf)设置一个只有Typeface风格的字体:有五种形式编程实现以上静态域字体1创建新工程2修改mianActivity.java,实现多种字体TextView显示package zyf.Typefac

15、eStudy;/*导入要使用的包*/import android.app.Activity;import android.graphics.Color;import android.graphics.Typeface;import android.os.Bundle;import android.view.ViewGroup;import android.widget.LinearLayout;import android.widget.TextView;public class TypefaceStudy extends Activity /* Called when the activit

16、y is first created. */ /* * android.graphics.Typeface java.lang.Object Typeface类指定一个字体的字体和固有风格. * 该类用于绘制,与可选绘制设置一起使用, 如textSize, textSkewX, textScaleX 当绘制(测量)时来指定如何显示文本. */ /* 定义实例化一个 布局大小,用来添加TextView */ final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT; /* 定义TextView对象 */ private TextVi

17、ew bold_TV, bold_italic_TV, default_TV, default_bold_TV,italic_TV,monospace_TV, normal_TV,sans_serif_TV,serif_TV; /* 定义LinearLayout布局对象 */ private LinearLayout linearLayout; /* 定义LinearLayout布局参数对象 */ private LinearLayout.LayoutParams linearLayouttParams; Override public void onCreate(Bundle icicle)

18、 super.onCreate(icicle); /* 定义实例化一个LinearLayout对象 */ linearLayout = new LinearLayout(this); /* 设置LinearLayout布局为垂直布局 */ linearLayout.setOrientation(LinearLayout.VERTICAL); /*设置布局背景图*/ linearLayout.setBackgroundResource(R.drawable.back); /* 加载LinearLayout为主屏布局,显示 */ setContentView(linearLayout); /* 定

19、义实例化一个LinearLayout布局参数 */ linearLayouttParams = new LinearLayout.LayoutParams(WRAP_CONTENT,WRAP_CONTENT); constructTextView(); setTextSizeOf(); setTextViewText() ; setStyleOfFont(); setFontColor(); toAddTextViewToLayout(); public void constructTextView() /* 实例化TextView对象 */ bold_TV = new TextView(th

20、is); bold_italic_TV = new TextView(this); default_TV = new TextView(this); default_bold_TV = new TextView(this); italic_TV = new TextView(this); monospace_TV=new TextView(this); normal_TV=new TextView(this); sans_serif_TV=new TextView(this); serif_TV=new TextView(this); public void setTextSizeOf() /

21、 设置绘制的文本大小,该值必须大于0 bold_TV.setTextSize(24.0f); bold_italic_TV.setTextSize(24.0f); default_TV.setTextSize(24.0f); default_bold_TV.setTextSize(24.0f); italic_TV.setTextSize(24.0f); monospace_TV.setTextSize(24.0f); normal_TV.setTextSize(24.0f); sans_serif_TV.setTextSize(24.0f); serif_TV.setTextSize(24.

22、0f); public void setTextViewText() /* 设置文本 */ bold_TV.setText(BOLD); bold_italic_TV.setText(BOLD_ITALIC); default_TV.setText(DEFAULT); default_bold_TV.setText(DEFAULT_BOLD); italic_TV.setText(ITALIC); monospace_TV.setText(MONOSPACE); normal_TV.setText(NORMAL); sans_serif_TV.setText(SANS_SERIF); seri

23、f_TV.setText(SERIF); public void setStyleOfFont() /* 设置字体风格 */ bold_TV.setTypeface(null, Typeface.BOLD); bold_italic_TV.setTypeface(null, Typeface.BOLD_ITALIC); default_TV.setTypeface(Typeface.DEFAULT); default_bold_TV.setTypeface(Typeface.DEFAULT_BOLD); italic_TV.setTypeface(null, Typeface.ITALIC);

24、 monospace_TV.setTypeface(Typeface.MONOSPACE); normal_TV.setTypeface(null, Typeface.NORMAL); sans_serif_TV.setTypeface(Typeface.SANS_SERIF); serif_TV.setTypeface(Typeface.SERIF); public void setFontColor() /* 设置文本颜色 */ bold_TV.setTextColor(Color.BLACK); bold_italic_TV.setTextColor(Color.CYAN); defau

25、lt_TV.setTextColor(Color.GREEN); default_bold_TV.setTextColor(Color.MAGENTA); italic_TV.setTextColor(Color.RED); monospace_TV.setTextColor(Color.WHITE); normal_TV.setTextColor(Color.YELLOW); sans_serif_TV.setTextColor(Color.GRAY); serif_TV.setTextColor(Color.LTGRAY); public void toAddTextViewToLayou

26、t() /* 把TextView加入LinearLayout布局中 */ linearLayout.addView(bold_TV, linearLayouttParams); linearLayout.addView(bold_italic_TV, linearLayouttParams); linearLayout.addView(default_TV, linearLayouttParams); linearLayout.addView(default_bold_TV, linearLayouttParams); linearLayout.addView(italic_TV, linea

27、rLayouttParams); linearLayout.addView(monospace_TV, linearLayouttParams); linearLayout.addView(normal_TV, linearLayouttParams); linearLayout.addView(sans_serif_TV, linearLayouttParams); linearLayout.addView(serif_TV, linearLayouttParams); 3结果更改手机窗口画面底色drawable 定义颜色常数的方法1编写main布局EditText android:id=+id/name_in android:layout_width=120dip android:l

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

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