实现点击箭头,展示更多text内容

来源:互联网 发布:mac俄罗斯红色号 编辑:程序博客网 时间:2024/06/07 02:18


实现的原理为设置TextView的属性,lines,默认可以设置为一行或者两行,当点击的时候,将lines属性设置为多行,就可以实现我们想要的效果。

<TextView
                android:id="@+id/tv_trademark_explanation"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                android:drawableBottom="@drawable/tv_down_arrow"
                android:drawablePadding="10dp"
                android:ellipsize="end"
                android:lines="2"
                android:paddingBottom="11dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:text=""
                android:textColor="@color/text_color_646464"

                android:textSize="13sp" />


case R.id.tv_trademark_explanation:
switch (tag) {
case 2:
tv_trademark_explanation.setMaxLines(100);
tag = 1;
break;
case 1:
tv_trademark_explanation.setLines(2);

tag = 2;
break;
default:
break;
}
break;
0 0