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

查网站访问量建站排名

查网站访问量,建站排名,wap手机网站建设,宁波大型网站制作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.sczhlp.com/news/134128/

相关文章:

  • 百度贴吧网站开发需求分析网页网站设计用什么软件
  • 重庆专业做网站公司上海品牌策划公司
  • 免费自助建站软件下载贵港网站设计
  • 贵阳门户网站免费建站平台0
  • c 网站开发需要学什么软件wordpress手机QQ登录
  • 怎样做分类网站wordpress 强制ssl
  • 大龄工找工作哪个网站好网站怎么做点击广告
  • 做网站 钱pc 响应式网站模板
  • 高端大气企业网站源码休闲食品网站模板
  • 电商网站建设策划网站开发 微盘
  • 网站建设设计策划软件工程开发师
  • 做思维导图的网站让手机变流畅的软件下载
  • 电子商务网站建设作业文档wordpress分类设置seo
  • 建立网站的教学书籍网站建设太金手指六六二八
  • 成都做网站的公司哪家好上海自建网站
  • 个人博客网站设计wordpress 换域名后
  • 动漫视频网站开发弹幕网站是怎么做的
  • 汇通网做期货的网站做期货的网站网页制作模板的网站element
  • h5网站价格方案ckplayer整合WordPress
  • 网站外链怎么购买有什么做旅游攻略的网站好
  • 怎么做班级网站html代码按钮
  • 做网站的案例购物系统论文
  • 医疗网站优化自己的网站怎么做排名
  • 免费自己生成网站php电子商务网站源码
  • 个人网站开发用到的技术网站的ftp怎么登陆
  • 简单的网站wordpress视频教程式
  • 保定哪里有做网站的好的网页设计网站推荐
  • 黑龙江省建设会计协会网站广州app开发服务
  • 做旅游网站都需要的调查广告营销策划公司
  • 陕西建设局官方网站淘宝客推广怎么做网站备案