一个简单的文本缩放效果
Boolean tvflag = true;
private int count;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
final TextView tv = (TextView) findViewById(R.id.tv);
tv.setText("asdfasdfasdfasdffffffffffffffffffffffffffffffffffffff");
tv.setSingleLine(false);
tv.setLines(3);
tv.setEllipsize(TextUtils.TruncateAt.END);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv.setSingleLine(false);
if (tvflag) {
tv.setEllipsize(null); // 展开
} else {
tv.setLines(3);
tv.setEllipsize(TextUtils.TruncateAt.END); // 收缩
}
tvflag = !tvflag;
}
});
}
}