我想自定义我的android edittext,以便:
所以它看起来像这样,例如:
..edittext [button]
而不是将文字放在按钮下
答案 0 :(得分:0)
尝试使用EditText android:drawableRight="@drawable/ic_calender"
在Edittext中设置图标设置最大行属性android:maxLines="1"
<EditText
android:layout_width="match_parent"
android:drawableRight="@drawable/ic_calender"
android:ellipsize="start"
android:maxLines="1"
android:text="tjhdshdhsdhjdhd"
android:layout_height="wrap_content" />
,您也可以像这样设置点击监听器
editText.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_LEFT = 0;
final int DRAWABLE_TOP = 1;
final int DRAWABLE_RIGHT = 2;
final int DRAWABLE_BOTTOM = 3;
if(event.getAction() == MotionEvent.ACTION_UP) {
if(event.getRawX() >= (editComment.getRight() - editComment.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
// your action here
return true;
}
}
return false;
}
});