2017-02-26 2 views
1

Ich verwende eine EditText. aber der Cursor beginnt in der Mitte des Bildschirms. Wenn ich wrap_content in der XML-Datei verwende, kann ich die EditText überhaupt nicht sehen (es ist ausgeblendet).Wie man editText Cursor bewegt?

Ich möchte, dass der Cursor und der Eingabetext oben in meiner Symbolleiste beginnen. Irgendwelche Ideen?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_settings_contact_us" 
    android:orientation="vertical" 
    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="airjaw.butterflyandroid.SettingsContactUsActivity"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/my_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     android:elevation="4dp" 
     android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/editText" 
     /> 

    <Button 
     android:text="Send" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="15dp" 
     android:id="@+id/submitButton" 
     android:onClick="submitButtonPressed"/> 

</RelativeLayout> 

Wie

enter image description here

+0

füge Sie das komplette Layout hinzu –

Antwort

1

Verwendung android:gravity="top" in Ihrem EditText wenn Sie

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/editText" 
    android:gravity="top" 
    /> 

bearbeiten nach oben müssen, um den Cursor bewegen: Verwenden Sie android:layout_marginTop="?attr/actionBarSize", ob es eine Überlappung oder dass, ohne dass Sie selbst android:layout_below="@+id/my_toolbar"

verwenden können

Bearbeiten 2: Verwenden Sie android:fitsSystemWindows="true in Ihrem Root-Layout wo @id activity_settings_contact_us und verwenden Sie android:windowSoftInputMode="adjustResize" unter Ihrem Aktivitäts-Tag @ Manifest! Dies ist für Sie die letzte Frage im Kommentar

+0

Leider überschneidet sich das mit meiner Symbolleiste und ich kann den Text nicht sehen. – makthrow

+0

@makthrow fügen Sie dann einen Rand mit der Höhe der Werkzeugleiste zu Ihrer Bearbeitungsansicht mit '? Attr/actionBarSize' –

+0

@makthrow Wie ist es jetzt^_^ –

0

Ändern der Androide: Breite auf einen Wert dp. Bsp.

<EditText 
    android:layout_width="320dp" 
    android:layout_height="match_parent" 
    android:id="@+id/myEditText1" /> 
+0

Funktioniert nicht für mich. Ich kann den eingegebenen Text nicht sehen. – makthrow

0

Versuchen Sie, LinearLayout anstelle von RelativeLayout zu verwenden.

Verwandte Themen