android:TextView相关使用问题
2016-09-28 12:19
423 查看
1、TextView的Layout属性:
wrap_content:包裹实际文本内容;
match_parent:当前控件铺满父类容器,2.3API之后
fill_parent:当前控件铺满父类容器,2.3API之前
2>、TextView的跑马灯效果实现
1、实现4个属性:
android:singleLine = "true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
2、创建一个继承TextView的子类
//添加构造函数 Source --> Generate Constructors from Superclass
public class MarqueeText extends TextView {
public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public boolean isFocused() {
return true;
}
4、修改TextView的引用:<com.example.textview.MarqueeTex
2>、AutoCompleteTextView实现自动匹配输入内容
//第一步:初始化控件
//第二步:需要一个适配器
//第三步:初始化数据源 -- 这数据源去匹配文本框中的数据
//第四步:讲adpter与当前autoCompleteTextView进行绑定
acTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, res);
acTextView.setAdapter(adapter);
private AutoCompleteTextView acTextView;
private String[] res = {"beijing1", "beijing2", "beijing3", "shanghai"};
android:completionThreshold="3" //输入几个开始自动匹配
3>、 MultiAutoCompleteTextView 可支持选择多个值得匹配,分别用分隔符分开,比如输入邮件
独特属性:设置分隔符的样式 mtxt.setTokenizer(new MultiAutoCompleteTextView.Commatokenizer());
wrap_content:包裹实际文本内容;
match_parent:当前控件铺满父类容器,2.3API之后
fill_parent:当前控件铺满父类容器,2.3API之前
2>、TextView的跑马灯效果实现
1、实现4个属性:
android:singleLine = "true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
2、创建一个继承TextView的子类
//添加构造函数 Source --> Generate Constructors from Superclass
public class MarqueeText extends TextView {
public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public boolean isFocused() {
return true;
}
4、修改TextView的引用:<com.example.textview.MarqueeTex
2>、AutoCompleteTextView实现自动匹配输入内容
//第一步:初始化控件
//第二步:需要一个适配器
//第三步:初始化数据源 -- 这数据源去匹配文本框中的数据
//第四步:讲adpter与当前autoCompleteTextView进行绑定
acTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, res);
acTextView.setAdapter(adapter);
private AutoCompleteTextView acTextView;
private String[] res = {"beijing1", "beijing2", "beijing3", "shanghai"};
android:completionThreshold="3" //输入几个开始自动匹配
3>、 MultiAutoCompleteTextView 可支持选择多个值得匹配,分别用分隔符分开,比如输入邮件
独特属性:设置分隔符的样式 mtxt.setTokenizer(new MultiAutoCompleteTextView.Commatokenizer());
相关文章推荐
- android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法
- android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法
- Android开发之Viewpager与TextView结合使用时不能滑动的问题
- android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法
- android textview drawableleft使用时遇到的问题
- Android textview 加载html语言(解决超链接不能使用的问题)
- Android TextView 常见问题与使用总结
- Android 控件之TextView常见使用问题
- android textview显示GIF解决花屏问题,使用Glide4.0+,别犹豫,全网只有我这有写
- Android WebView使用及苏宁易付宝支付相关问题
- Android TextView 常见问题与使用总结
- android TextView多行文本(超过3行)使用ellipsize="end"属性无效问题的解决方法
- CheckedTextView的使用、学android疯狂讲义第二版遇到的问题希望能帮到和我一样的初学者、新手
- android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法
- android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法
- Android TextView 使用HTML格式串
- Android的TextView使用Html来处理图片显示、字体样式、超链接等
- android中使用TextView来显示某个网址的内容,使用<ScrollView>来生成下拉列表框
- android 悬浮窗使用surfaceview的问题
- Android 3.X中WebView使用ZOOM崩溃的问题