文档详情

Android记事本分析和总结.docx

发布:2024-04-24约3.42千字共5页下载文档
文本预览下载声明

只是在主程序里面添加此代码:

TextViewtextView=newTextView(this);textView.setText(你好啊);setContentView(textView);

就会在Android虚拟机上显示“你好啊”

只在Main.xml里面添加代码:

TextViewandroid:layout_width=fill_parentandroid:layout_height=wrap_contentandroid:text=你好

/

3.设置超链接:android:autoLink=”all”

3.

跑马灯:android:singleLine=”true”把所以要跑马灯的都显示成

一行android:focusable=trueandroid:ellipsize=marquee

android:marqueeRepeatLimit=marquee_foreverandroid:focusableInTouchMode=true

设置字体颜色:

TextViewtv=(TextView)findViewById(R.id.tv);

Stringstr=欢迎大家收看《Android开发从零开始》系列课程,感谢大家的支持。;

SpannableStringBuilderstyle=newSpannableStringBuilder(str);style.setSpan(newForegroundColorSpan(Color.RED),0,6,

Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

style.setSpan(newForegroundColorSpan(Color.GREEN),6,21,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

style.setSpan(newForegroundColorSpan(Color.BLUE),21,26,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

tv.setText(style);

7.

8.

privateAlphaAnimationan1=newAlphaAnimation(1,0);定义他的@动画,是android

自带的

an1

an1.setDuration(1000);休息的时间问1000毫秒

imgv1.startAnimation(an1);//startAnimation启动动画

给自己的界面设置空间大小Android:layout_weight=”X”

实现图片的循环

a先取得getContext的返回最大值PublicintgetContext(){

ReturnInteger.MAX_VALUE;

}

b有就是设置图片给ImageView对象Imageview.setImageResource(resides[position%resIds.length]);c.我们还可以给图片添加一个边框

首先定义一个intmGalleryItemBackground;,然后取得Gallery属性的Indexid的值

publicImageAdapter(Contextc){mContext=c;

//使用在res/value/attrs.xml中的Gallery属性

TypedArraya=obtainStyledAttributes(R.styleable.Gallery);

//取得Gallery属性的IndexidmGalleryItemBackground=a.getResourceId(

R.styleable.Gallery_android_galleryItemBackground,0);

//让对象的styleable属性能够反复使用a.recycle();

}

在res/value/attrs.xml的代码

declare-styleablename=Gallery

attrname=android:galleryItemBackground/

/declare-styleable

AlertDialog的使用

AlertDialog.Builderbuilder=newAlertDialog.Builder(

C018_onDoubleClickActivity.this);builder.setTitle(双击);builder.setMessage(VeryGood);builder.show();

图片的淡进淡出:A

显示全部
相似文档