need EditText with readonly indent

跟風遠走 提交于 2019-12-13 03:06:34

问题


Does anyone have ideas on how to achieve a blank indent on the first line of an EditText such that the user cannot modify the indent?

My goal is to superimpose some other info (possibly graphics) in the indent area and still allow the rest of the EditText to wrap long lines back to the normal left margin.

Fallback would be to add a separate line or column for the "other info", but that isn't as good a use of the screen real estate.

Perhaps there is better way to do this. Suggestions are welcome!


回答1:


I'm not sure on what are you trying to do but you can "modify" dinamically the text while is prompted.

Use a TextWatcher that offers you three method called in order. Try in debug with some breakpoints to understand better the variables and use them!

((EditText) findViewById(R.id.myEditText)).addTextChangedListener(new TextWatcher() {
      @Override
      public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

      @Override
      public void onTextChanged(CharSequence s, int start, int before, int count) {}

      @Override
      public void afterTextChanged(Editable s) {}
});


来源:https://stackoverflow.com/questions/14754663/need-edittext-with-readonly-indent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!