Reputation: 1411
There is difference between text edit added in activity_main.xml and one added from code.
That is how they look.
Code of EditText added from xml.
And code of EditText added programmatically.
Function getDisplayInfo just get width and height of the screen. It does nothing connected with ui.
Upvotes: 0
Views: 74
Reputation: 2011
EditText
added from xml has preformed look and feel but if we are adding it from java code it may require to set additional attributes to set look and feel
EditText etName = new EditText(getApplicationContext());
etName.setBackgroundResource(R.drawable.BlueBackground);
Upvotes: 0
Reputation: 44571
It looks like it's because the background color isn't set on the new EditText
since the background color is set in xml then you add a View
to it. You need to then set the background color to your newly added EditText
.
I believe something like
editT.setBackgroundColor(Color.parseColor("#0F0"));
should work.
Upvotes: 1