• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to Reduce size of EditText programmatically

wertyu

Newbie
Hi,

In my sample application I'm using a LinearLayout and not using the layout XML. I have defined an EditText but it spans the width of the layout and I want to make it much smaller. I've called setWidth but it had no effect. Can anyone help? Thanks!

Code;

EditText symbol;

protected​
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

LinearLayout layout =
new LinearLayout(this);
layout.setOrientation(LinearLayout.
VERTICAL);

symbol =new EditText(this);

symbol.setMaxWidth(300);
layout.addView(symbol);
 
Back
Top Bottom