1. Check out our companion app, Forums for Android! Download from Google Play

Apps How to Reduce size of EditText programmatically

Discussion in 'Android Development' started by wertyu, Feb 4, 2010.

  1. wertyu

    wertyu Member
    Thread Starter
    15

    Oct 5, 2009
    13
    0
    15
    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);
     

    Advertisement

Share This Page

Loading...