想实现吗?
在网上找了很久,说的五花八门....但是,都不是我想要的效果...
我说个思路,自己实现哈,在edittext 外面再套一层 RelativeLayout ,edittext 宽高都是 match_parent ,然后再后面跟一个view 宽高也是
match_parent ,然后设置view的点击事件,点击view就让edittext获得焦点,这样就有光标,也不会弹出小键盘啦.
获得焦点的方法:
edit1_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { code_edit.setFocusable(true); code_edit.setFocusableInTouchMode(true); code_edit.requestFocus(); code_edit.findFocus(); } });
<RelativeLayout android:layout_width="match_parent" android:layout_height="@dimen/dp_50_x"> <EditText android:id="@+id/code_edit" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/edit_shape" android:gravity="center|left" android:hint="登录账号" android:inputType="number" android:maxLength="18" android:focusable="true" android:focusableInTouchMode="true" android:textColor="#000000" android:paddingLeft="@dimen/dp_10_x" android:textColorHint="#cccccc" android:textCursorDrawable="@null" android:textSize="@dimen/dp_16_x" /> <View android:id="@+id/edit1_view" android:layout_width="match_parent" android:layout_height="match_parent"></View> </RelativeLayout>
如果有更好的办法,请在下方留言..