I’m trying to get all edit text views to be the same size without using a hard definition like px or dp, but rather to use a wrap_content and get them all to be the same size. This is what I have, but it doesn’t work:
enterAge = (EditText) findViewById(R.id.enterAge);
enterAge.addTextChangedListener(new TextWatcher1());
enterWeight = (EditText) findViewById(R.id.enterWeight);
enterWeight.addTextChangedListener(new TextWatcher2());
enterWeight.setWidth(enterAge.getWidth());
enterHeight = (EditText) findViewById(R.id.enterHeight);
enterHeight.addTextChangedListener(new TextWatcher3());
enterHeight.setWidth(enterAge.getWidth());
enterMealFrequency = (EditText) findViewById(R.id.enterMealFrequency);
enterMealFrequency.addTextChangedListener(new TextWatcher4());
enterMealFrequency.setWidth(enterAge.getWidth());
Any suggestions on why this isn’t working the way I want it to?
I have solved similar problem introducing my own class which extends EditText, e.g.
In resource you can directly use reference to SimpleEditText instead of EditText (for sure one have to keep in mind that all size related XML attributes will be ignored…)