答案 0 :(得分:3)
这件事应该有效:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ABCABCABACBACBACBACBAC"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end"
android:drawableRight ="@drawable/ic_info" />
答案 1 :(得分:0)
试试这个android:ellipsize="end"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="@drawable/images"
android:ellipsize="end"
android:maxLines="1"
android:text="Large Text fgkjdsfgkjdfslgk jdsfg jdfgjdfjgijdfogjdfgdfsgdfsg dfsg dfsg sdf g"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="@drawable/images"
android:ellipsize="end"
android:maxLines="1"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
答案 2 :(得分:0)
在上面的评论中,你已经要求听众在drawableRight上点击事件,这是对它的实现
yourTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_RIGHT = 2;
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (event.getRawX() >= (yourTextView.getRight() - yourTextView.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
return true;
}
}
return false;
}
});