How to Reduce size of EditText programmatically

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

  1. wertyu

    wertyu Member
    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...