Friday, May 17, 2013

[android help] Android form elements have different sizes on different emulators


Update #1


I observed that setting the text size as 20sp will cause the input elements to appear normally on devices smaller than 5". It seems that reducing the text size did not reduce the size of the input box. Is this supposed to be normal?


TLDR version


Hi there,


I am facing a problem with the size of input elements in my Android project. The input elements appear larger on devices that are < 5" in size, but appear otherwise normal on my larger devices.


The below screenshots illustrate this. Any idea what could be the cause?


Detailed version


Hi there,


I am currently facing an odd problem with the size of my form elements in my Android project across different emulators. As this is the first time I am creating a mobile application, please feel free to enlighten me if this is a "feature", rather than a bug.


On the Nexus 7 layout preview, the form elements appear as I expected:


enter image description here


However, on the Galaxy Nexus layout preview, the form elements appear larger than expected, which is not desirable:


enter image description here


I have tried many methods, but have been unable to resolve this problem. This problem occurs on all devices that are less than 5" in screen size.


Here is my layout XML file:



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

android:id="@+id/register_link"
style="@style/FormFont.Label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:clickable="true"
android:onClick="onClickRegisterLink"
android:text="@string/register_link_text" />

android:id="@+id/layout_layout_form"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="@+id/register_link"
android:gravity="center" >

android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/layout_form"
android:layout_alignRight="@+id/layout_form"
android:layout_marginBottom="50dp"
android:contentDescription="@string/logo_description"
android:src="@drawable/logo" />

android:id="@+id/layout_form"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/logo"
android:gravity="center" >

android:id="@+id/label_username"
style="@style/FormFont.Label"
android:layout_alignBottom="@+id/input_username"
android:layout_alignLeft="@+id/label_password"
android:layout_alignRight="@+id/label_password"
android:layout_alignTop="@+id/input_username"
android:layout_toLeftOf="@+id/input_username"
android:gravity="right"
android:text="@string/label_username" />

android:id="@+id/label_password"
style="@style/FormFont.Label"
android:layout_alignBottom="@+id/input_password"
android:layout_alignTop="@+id/input_password"
android:layout_below="@+id/label_username"
android:layout_marginRight="50dp"
android:layout_toLeftOf="@+id/input_password"
android:gravity="right"
android:text="@string/label_passphrase" />

android:id="@+id/input_username"
style="@style/FormFont.Input"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:inputType="text" />

android:id="@+id/input_password"
style="@style/FormFont.Input"
android:layout_alignLeft="@+id/input_username"
android:layout_alignRight="@+id/input_username"
android:layout_below="@+id/input_username"
android:layout_marginTop="30dp"
android:inputType="textPassword" />

android:id="@+id/button_login"
style="@style/FormFont.Label"
android:layout_alignLeft="@+id/input_password"
android:layout_alignRight="@+id/input_password"
android:layout_below="@+id/input_password"
android:layout_marginTop="35dp"
android:gravity="center"
android:text="@string/button_login" />







My /res/values/styles.xml:




















My /res/values-large/styles.xml:




















Please let me know if you have encountered this before and have an idea of what could be the cause :) Thank you very much!



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...