第二十三天 TextView、Button
来源:互联网 发布:Windows 10 修复模式 编辑:程序博客网 时间:2024/05/16 09:54
TextView
textViewPhone.setTextColor(Color.BLUE);//设置文本颜色textViewPhone.setAutoLinkMask(Linkify.PHONE_NUMBERS);//拨打电话(android:autoLink="phone")//上网(android:autoLink="web")textViewPhone.setText("拨打电话:18500292306");//要写在setAutoLinkMask一句的后面
textViewPrice=(TextView)findViewById(R.id.textViewPrice); textViewPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);//在text上加上中划线
textViewImg=(TextView)findViewById(R.id.textView_img); String text="我是一个<font color='#ff0000'>富文本</font>,然后末尾加一个图标<img src='a_main_icon08'/>"; Html.ImageGetter getter=new Html.ImageGetter() { @Override public Drawable getDrawable(String source) { int id=R.mipmap.ic_launcher; Class clazz=R.mipmap.class; try { Field field = clazz.getDeclaredField(source); id=field.getInt(clazz); } catch (IllegalAccessException e) { e.printStackTrace(); }catch (NoSuchFieldException e) { e.printStackTrace(); } Drawable drawable=getResources().getDrawable(id); drawable.setBounds(0,0,drawable.getIntrinsicHeight(),drawable.getIntrinsicWidth()); return drawable; } }; Spanned spanned=Html.fromHtml(text,getter,null); textViewImg.setText(spanned);
文本滚动 界面小设计
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/textView1" android:layout_width="200dp" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee"//跑马灯 android:focusable="true" android:focusableInTouchMode="true" android:text="08-21 02:42:37.324 27265-27265/com.example.D/OpenGLRenderer﹕ TextureCache::get: create texture(0xb7d26868)" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="bottom">//置于底部 <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:drawableTop="@mipmap/ic_launcher" android:text="消息" android:gravity="center_horizontal" android:layout_weight="1"/> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:drawableTop="@mipmap/ic_launcher" android:text="联系人" android:gravity="center_horizontal"/> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:drawableTop="@mipmap/ic_launcher" android:text="动态" android:gravity="center_horizontal"/> </LinearLayout></RelativeLayout>
登录小界面
android:hint=”请输入密码” (EditText中的提示语)
password=true(密码不可见)
editText_password=(EditText)findViewById(R.id.editText_password);Button button=(Button)findViewById(R.id.button);button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editText_password.setTransformationMethod(null); } });//设置密码可见
Button
ninepatch:上左代表拉伸、下右代表内容
当按下按钮时,按钮变成其他颜色(使用SDK下tools中的draw9patch工具编辑图片)
drawable
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@mipmap/back" android:state_pressed="true"/> <item android:drawable="@mipmap/picture9" /></selector>
Button
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="密码可见" android:id="@+id/button"android:background="@drawable/back_drawable"/>
RadioButton
public class MainActivity extends Activity { private RadioGroup mRadioGroup; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.radio_layout); mRadioGroup= (RadioGroup) findViewById(R.id.radioGroup); mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton rb= (RadioButton) findViewById(checkedId); Log.d("sex","您的性别是:"+rb.getText()); } }); }}
0 0
- 第二十三天 TextView、Button
- 世界杯第二十三天
- 第二十三天:总结
- 第二十三天
- 第二十三天:多线程
- 第二十三天总结
- 第二十三天总结
- 第二十三天:听课笔记
- php实战第二十三天
- 拓胜第二十三天
- 实习篇---第二十三天
- UI第二十三天:动画
- 第二十三天学习笔记
- 第二十三天H5进阶
- jQuery选择器---第二十三天
- Java学习第二十三天
- 第二十三天 时间函数
- 连续总结第二十三天
- 社説 20150821 広島土石流1年 教訓を早期避難に生かしたい
- mysql数据库索引
- java打包成jar后读取外部文件
- 136Single Number
- JAVA泛型-类型擦除太恶心,但项目中大量使用,以及类型擦除引起的问题及解决方法
- 第二十三天 TextView、Button
- android EditText 有边框 透明样式
- 社説 20150821 サイバー新戦略 官民で専門技術者を育成せよ
- 哈希(Hash)算法
- CentOS 6.x 编译安装varnish 3.x
- Gephi—结合GeoLayout和Maps of countries layouts的地理位置布局
- 从美国药物管制说起
- keep old customs or follow new ones
- apue源码运行配置