Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the height of a EditText and a Button?

I have this EditText and Button, and I have to reduce its height. I try with android:height="10px" but it doesn't work. Btw android:width="180px" works OK, then I don't know why I can't adjust the height.

Here is the code:

<EditText 
    android:id="@+id/Movile"
    android:layout_alignBaseline="@+id/MovileLabel"
    android:layout_alignParentRight="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:width="180px"
    android:height="10px"/>

<Button
        android:id="@+id/inviteButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/invite"
        android:width="100px"
        android:height="5px"
        android:layout_marginLeft="40dip"/>
like image 290
NullPointerException Avatar asked Nov 10 '10 15:11

NullPointerException


People also ask

How do I change my EditText value?

This example demonstrates how do I set only numeric value for editText in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I get the length of EditText content?

getText(). toString(). length()); } });


4 Answers

Instead of setting values to android:height="10px" use android:layout_height="10px"

 android:layout_width="180px"
 android:layout_height="10px"
like image 74
Labeeb Panampullan Avatar answered Oct 19 '22 16:10

Labeeb Panampullan


use android:minHeight="120dp" attribute.

if need to increase height dynamically add android:layout_height="wrap_content"

like image 31
Janith Avatar answered Oct 19 '22 15:10

Janith


You need to get rid of the "wrap_content" properties and just have the fixed width and height as so:

<EditText 
    android:id="@+id/Movile"
    android:layout_alignBaseline="@+id/MovileLabel"
    android:layout_alignParentRight="true"
    android:layout_width="180px"
    android:layout_height="10px"/>

<Button
        android:id="@+id/inviteButton"
        android:text="@string/invite"
        android:layout_width="100px"
        android:layout_height="5px"
        android:layout_marginLeft="40dip"/>
like image 42
bassburner Avatar answered Oct 19 '22 14:10

bassburner


You can't decrase size of TextEdit if the font is too big inside.

try android:textSize='6sp'

like image 21
yosh Avatar answered Oct 19 '22 14:10

yosh