当前位置: 首页 > news >正文

济南网站建设济南宁波网站排名提升

济南网站建设济南,宁波网站排名提升,印度做爰免费网站视频,wordpress虎嗅网Android开发展开收起功能 文字过长展开收起功能很普通,也很需要。 一、思路: 自定义控件MoreTextView 二、效果图: 三、关键代码: public class MoreTextView2 extends LinearLayout {/*** TextView的实际高度*/private int …
Android开发展开收起功能

文字过长展开收起功能很普通,也很需要。

一、思路:

自定义控件MoreTextView

二、效果图:

在这里插入图片描述
在这里插入图片描述

三、关键代码:
public class MoreTextView2 extends LinearLayout {/*** TextView的实际高度*/private int textViewHeight;/*** 默认全文的Text*/private static final String EXPANDEDTEXT = "全文";/*** 默认收起的text*/private static final String COLLAPSEDTEXT = "收起";/*** 全文的text*/private String expandedText;/*** 收起的text*/private String collapsedText;/*** 字体大小*/private int textSize;/*** 字体颜色*/private int textColor;/*** 超过多少行出现全文、收起按钮*/private int trimLines;/*** 显示文本的TextView*/private TextView showTextView;/*** 全文和收起的TextView*/private TextView collapseTextView;/*** 是否是收起状态,默认收起*/private boolean collapsed = true;private boolean show;public MoreTextView2(Context context, AttributeSet attrs) {super(context, attrs);initView(context, attrs);}public MoreTextView2(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);initView(context, attrs);}@TargetApi(Build.VERSION_CODES.LOLLIPOP)public MoreTextView2(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {super(context, attrs, defStyleAttr, defStyleRes);initView(context, attrs);}private void initView(Context context, AttributeSet attrs) {showTextView = new TextView(context);setOrientation(VERTICAL);TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MoreTextView2);textColor = typedArray.getColor(R.styleable.MoreTextView2_textColor, Color.GRAY);textSize = typedArray.getDimensionPixelSize(R.styleable.MoreTextView2_textSize, 14);expandedText = typedArray.getString(R.styleable.MoreTextView2_expandedText);if (TextUtils.isEmpty(expandedText)) {expandedText = EXPANDEDTEXT;}collapsedText = typedArray.getString(R.styleable.MoreTextView2_collapsedText);if (TextUtils.isEmpty(collapsedText)) {collapsedText = COLLAPSEDTEXT;}trimLines = typedArray.getInt(R.styleable.MoreTextView2_trimLines, 0);typedArray.recycle();showTextView.setTextSize(textSize);showTextView.setTextColor(textColor);showTextView.setLineSpacing(3f, 1.2f);//hint(没有自我介绍内容时的默认显示)SpannableString ss = new SpannableString(getResources().getString(R.string.formal_tips));//定义hint的值AbsoluteSizeSpan ass = new AbsoluteSizeSpan(14, true);//设置字体大小 true表示单位是spss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);showTextView.setHint(new SpannedString(ss));showTextView.setHintTextColor(getResources().getColor(R.color.text_aaa));addView(showTextView);}public void setText(CharSequence text) {showTextView.setText(text);globalLayout();requestLayout();invalidate();sum();}
四、项目demo源码结构图:

在这里插入图片描述有问题或者需要完整源码的私信我

http://www.laogonggong.com/news/62006.html

相关文章:

  • 上海高端网站建设公司做租赁哪个网站好
  • 美食网站开发现状毕业设计做一个网站怎么做
  • 中国质量建设协会网站网站开发与应用就业方向
  • 网站竞争案例没有足够的权限卸载2345网址导航
  • 做PPT的辅助网站广西壮锦网站建设策划书
  • 2008如何添加iis做网站焦作企业网站建设
  • 网加思维做网站推广京东这样的网站是怎么做的
  • 用自己照片做衣服 杯子的是哪个网站企业网站设计师
  • 制作网站可用性监控宁波优化系统
  • 上海网页设计经验培训珠海网站建设方案优化
  • 芙蓉区乡建设局网站推广平台有哪些平台
  • 服装购物网站的建设与技术论文网站代码是什么意思
  • 服装公司网站建设方案网站网站是怎么建设的
  • 网站建设公司.制作免费个人网页
  • 做非遗网站的原因jsp做的网站带数据库
  • 哈尔滨做网站哪家好广告设计公司简介内容
  • 做烘培的网站福州医社保增减员在什么网站做
  • 哈尔滨企业网站排名网站建设与维护 参考文献
  • 自建网站如何赚钱甘肃省住房和城乡建设厅网站
  • 什么公司需要建立网站吗做百度推广得用网站是吗
  • 无锡装修网站建设区服务网站
  • 建站网址导航hao123贵阳网站建设seo公众号开发
  • 网站一般用什么做的济南网红
  • 绍兴网站制作推广html企业网站主页模板
  • 网站模板安装教程国家公示企业信息查询系统
  • 赶集网网站建设ppt模板游戏网站平台怎么做的
  • 新做的网站怎样让百度收录东莞市公共资源交易中心
  • 国外销售网站怎样建设珠海软件开发公司
  • 育贤网站建设企业融资的三种方式
  • 彩票创建网站国家企业信用信息公示系统辽宁