4.TextView中有个ellipsize属性,作用是当文字过长时,该控件该如何显示,解释如下:
1.android:ellipsize=”start”―�C省略号显示在开头
2.android:ellipsize=”end”――省略号显示在结尾
3.android:ellipsize=”middle”―-省略号显示在中间
4.android:ellipsize=”marquee”�C以跑马灯的方式显示(动画横向移动)
文字左右滚动三个属性:
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
Android中我们为了实现文本的滚动可以在ScrollView中嵌入一个TextView,其实TextView自己也可以实现多行滚动的,毕竟ScrollView必须只能有一个直接的子类布局。只要在layout中简单设置几个属性就可以轻松实现。


1.

原文地址:android string.xml前后加空格的技巧作者:forzajuve1029sf3

string name="auto_deny">&#160;&#160;&#160;&#160;流量超过限额将自动禁用网络</string>

&#160 这个就代表着空格



2.从xml中加载文字

getResources().getString(R.string.welcome)


3.tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下划线
tv.setText("使用代码实现下划线样式");
tv.setTextColor(Color.WHITE);

在xml文件中使用android:textStyle="bold" 可以将英文设置成粗体,但是不能将中文设置成粗体,将中文设置成粗体的方法是:
TextView tv = (TextView)findViewById(R.id.TextView01);
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);
其他还有:
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);//设置成24sp
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//可能中文加粗无效
textView.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));//可能中文无效
textView.setText(Html.fromHtml("<u>"+texts+"</u>"));//下划线
textView.setTypeface(Typeface.MONOSPACE,Typeface.ITALIC);//斜体,中文有效
textView.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );//中间加横线
textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );//底部加横线



promotionLinkText = (TextView) this .findViewById(R.id. text_promotion_link );
中间加横线
promotionLinkText .getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );
底部加横线:
promotionLinkText .getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );

textView1.getPaint().setAntiAlias(true);// 抗锯齿


textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线 textView.getPaint().setAntiAlias(true);//抗锯齿 textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线 setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰

textView.getPaint().setFlags(0); // 取消设置的的划线


Android设置文字粗体的方法:
testTextView=(TextView) findViewById(R.id.testTextView);
testTextView.getPaint().setFakeBoldText(true);

英文和数字可以直接用XML去设置:
android:textStyle="bold"





更多相关文章

  1. Android(安卓)3.0 r1 API中文文档(113) ――SlidingDrawer
  2. Android中文联系人排序及检索补丁的原理(090819更新)
  3. android client随机验证码生成函数
  4. Android(安卓)中文API (69) ―― BluetoothAdapter[蓝牙]
  5. 【安卓笔记】android客户端向tomcat服务器发送请求中文乱码问题
  6. Android(安卓)Studio 修改默认作者信息和可用的模板
  7. Android中EditText中文英文长度控制
  8. Android(安卓)中文API (92) ―― MenuInflater
  9. android下libgdx 中文字符显示初探

随机推荐

  1. Android(安卓)开机logo动画
  2. Android3D游戏开发感觉
  3. android代码混淆
  4. Android系统的架构
  5. Android(安卓)GPS定位的简单应用
  6. Android(安卓)Studio GitHub 提交项目代
  7. 在Ubuntu 9.10下编译Android源码
  8. Android操作HTTP实现与服务器通信
  9. Android(安卓)Permission大全1.0最终版本
  10. android 三种定位方式