Android TextView文字超出一屏不能显示其它的文字 解决方案
2015-04-03 20:58
471 查看
在android上面让TextView 过多的文字实现有滚动条,之前想简单了以为设置TextView的属性就可以实现,结果还是需要ScrollView配合使用,才能达到滚动条的效果有两种方式实现,
一种是代码写java的layout:
另一种则用layout.xml来实现:
一种是代码写java的layout:
01.RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(80,80); 02.//初始化滚动条控件 03.ScrollView scrollView =new ScrollView(this); 04.scrollView.setScrollContainer(true); 05.scrollView.setFocusable(true); 06.//初始化文字控件 07.TextView textView = new TextView(this); 08.textView.setHorizontallyScrolling(true); 09.textView.setText("哈哈哈,\n哈哈哈"); 10. 11.scrollView.addView(textView); 12.main_view.addView(scrollView, param);
另一种则用layout.xml来实现:
01.<ScrollView 02. android:layout_width="fill_parent" 03. android:layout_height="fill_parent" 04. android:scrollbars="vertical" 05. android:fadingEdge="vertical"> 06. 07. <TextView 08. android:id="@+id/textView" 09. android:layout_width="wrap_content" 10. android:layout_height="wrap_content" 11. android:text="Demo" 12. android:textSize="15sp"/> 13. </ScrollView>
相关文章推荐
- Android TextView文字超出一屏不能显示其它的文字 解决方案
- Android TextView 判断文字内容是否超出显示省略号
- Android基础教程(一)之------更改与显示文字标签TextView标签的使用
- Android TextView文字过多时,通过滚动条显示多余内容
- Android基础教程(一)之------更改与显示文字标签TextView标签的使用
- Android TextView 显示文字阴影效果
- Android之TextView实现文字过长时省略部分或者滚动显示
- Android之TextView实现文字过长时省略部分或者滚动显示
- Android UI 如何让TextView中的文字居中显示
- android--设置TextView部分文字的颜色和背景(高亮显示)
- Android TextView中设定个别文字字体显示格式
- android--设置TextView部分文字的颜色和背景(高亮显示)
- Android的TextView实现文字高亮显示和显示表情
- Android TextView中设定个别文字字体显示格式或者高亮显示
- android textView文字过长,省略显示
- android textview 中超出屏幕宽度的字符 省略号显示
- Android TextView 显示文字阴影效果
- Android基础教程(一)之------更改与显示文字标签TextView标签的使用
- Android之TextView实现文字过长时省略部分或者滚动显示
- android--设置TextView部分文字的颜色和背景(高亮显示)