天天看点

android 更多 收起 简单实现

android 更多 收起 简单实现

private boolean moreflag = false;//初始化时给false  根据需求更改

txtMemo = (TextView) this.findViewById(R.id.memo);

txtMemo.setMaxLines(2);//初始化时设置最大行数为2两行

llyt_More = (LinearLayout) findViewById(R.id.housedetail_llyt_more);

// 更多

btn_More = (Button) findViewById(R.id.housedetail_btn_more);//更多文字

imgView_More = (ImageView) findViewById(R.id.housedetail_imgview_more);// 图片  向上  向下

btn_More.setOnClickListener(ocMore);//监听点击事件

private OnClickListener ocMore = new OnClickListener()

{

@Override

public void onClick(View v)

{

if (moreflag)

{

imgView_More.setImageResource(R.drawable.infomoredown);

txtMemo.setMaxLines(2);

btn_More.setText("更多");

moreflag = false;

}

else

{

imgView_More.setImageResource(R.drawable.infomoreup);

txtMemo.setMaxLines(200);

btn_More.setText("收起");

moreflag = true;

}

}

};

android 更多 收起 简单实现

效果图

android 更多 收起 简单实现