2017-02-26 12 views
1

私はEditTextを使用しています。カーソルは画面中央で開始されます。 xmlファイルにwrap_contentを使用すると、EditTextは表示されません(非表示になっています)。editTextカーソルの移動方法は?

カーソルと入力テキストが、ツールバーの一番上に表示されます。何か案は?

<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> 

どう

enter image description here

+0

フルレイアウトを追加 –

答えて

1

あなたEditText内で使用android:gravity="top"あなただけ

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

編集先頭にカーソルを移動する必要がある場合:任意の重複やそのせずに、あなたも使用できるがある場合android:layout_marginTop="?attr/actionBarSize"を使うandroid:layout_below="@+id/my_toolbar"

編集2:ルートレイアウトでandroid:fitsSystemWindows="trueを使用してください。@ id activity_settings_contact_usあなたのアクティビティタグ@マニフェストの下にandroid:windowSoftInputMode="adjustResize"を使用してください!これはコメントの最後の質問です

+0

残念ながら、それは私のツールバーと重なり、私はテキストを見ることができません。 – makthrow

+0

@makthrowその後、 '?attr/actionBarSize'を使用して、ツールバーの高さにマージンを編集テキストビューに追加します。 –

+0

@makthrowそれはどうですか^ _^ –

0

変更のandroid:DP値に幅。 Ex。

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

私のためには機能しません。私が入力しているテキストを見ることができません。 – makthrow

0

RelativeLayoutの代わりにLinearLayoutを使用してみてください。

関連する問題