How to Reduce size of EditText programmatically


Last Updated:

  1. wertyu

    wertyu Member This Topic's Starter

    Joined:
    Oct 5, 2009
    Messages:
    13
    Likes Received:
    0
    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...