上图是加载全部之前的
这是加载全部的,写的代码都是简单易懂的。
xml中的两个Textview
<TextView
android:id="@+id/tv_shop_storeIntroduce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:maxLength="5000"
android:singleLine="false"
android:lines="3"
android:ellipsize="end"
android:text="文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍" />
android:maxLength="100"
android:scrollHorizontally="false"/>
<TextView
android:layout_gravity="center_horizontal"
android:padding="@dimen/dp_10"
android:id="@+id/tv_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="加载更多"
android:drawablePadding="@dimen/dp_5"
android:drawableRight="@drawable/shop_more_arrow"
android:singleLine="true"/>
Java代码:
private boolean mapboolean = true;
case R.id.tv_load://点击事件
if (mapboolean) {
//加载全部的状态
mapboolean = false;
Drawable draw = getResources().getDrawable(R.drawable.shop_more_arrow);
mTvload.setCompoundDrawablesRelativeWithIntrinsicBounds(null,null,draw,null);
mTvload.setText("收起");
mTvshopstoreIntroduce.setEllipsize(null); // 展开
mTvshopstoreIntroduce.setSingleLine(mapboolean);
mTvshopstoreIntroduce.setEllipsize(TextUtils.TruncateAt.END);//以...的形式显示多余的
} else {
// 收缩后的状态
mapboolean = true;
Drawable draw = getResources().getDrawable(R.drawable.shop_down_xia);
mTvload.setCompoundDrawablesRelativeWithIntrinsicBounds(null,null,draw,null);
mTvshopstoreIntroduce.setLines(3);
mTvshopstoreIntroduce.setEllipsize(TextUtils.TruncateAt.END);
mTvload.setText("加载更多");
}
break;