mercredi 13 mai 2015

Android Studio - Strange xml glitch where cursor of edittext begins halfway through

I've run into some strange behaviour and can't figure out what the problem is. Please observe the xml code and screenshots below.

This is what my layout looks like in Android Studio:

enter image description here

This is what my layout looks like on my phone:

enter image description here

Now, the EditText should cover 60% of the upper screen, and it does, however the cursor begins halfway through and it is not possible to access any of the area of the EditText above that mark.

Here is my xml code for this file:

<LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.example.redacted.redacted.InputActivity">

<EditText
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.6"
    android:inputType="textMultiLine"
    android:id="@+id/editText" />

<RelativeLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.4" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btnCancel"
        android:onClick="onBtnInputCancel"
        android:id="@+id/button4"
        android:layout_gravity="end"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btnContinue"
        android:onClick="onBtnInputContinue"
        android:id="@+id/button5"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

</RelativeLayout>
</LinearLayout>

I've tried mixing the values around and adding/removing elements but the issue remain. My phone is a Samsung Galaxy S5, but surely these issues shouldn't occur on any device?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire