I want to make the EditText and the OK button same height, but always got the EditText slightly shorter than the Button.
I googled and tried the following way without succeed, nothing changed:
- set both the EditText and Button to same height in pixel
- wrap EditText and Button into a RelativeLayout. Set the height of the RelativeLayout and set EditText and Button both to fillparent in height
- set alignTop and alignBottom on the Button
The theme is: android:theme="@android:style/Theme.NoTitleBar.Fullscreen
Could someone please help me on this? Thanks!
Here is the xml:
<RelativeLayout android:id="@+id/login_layout_ipAddr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#CEE6F0"
android:visibility="invisible">
<RelativeLayout android:id="@+id/login_layout_inner_ipAddr"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText android:id="@+id/login_text_ipAddr"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:inputType="text"
android:textSize="5pt"
android:hint="@string/login_text_ipAddr" />
<Button android:id="@+id/login_btn_ipAddr"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#00ABDF"
android:textColor="#FFFFFF"
android:text="@string/login_btn_ipAddr"
android:onClick="updateIPaddr"/>
</RelativeLayout>
</RelativeLayout>
To create a button with fixed height and width, you can give values in both px or in dp.
giving values in dp is more convenient , because android automatically scale the height and width in ldpi,mdpi and hdpi devices.