2016-10-18 2 views
0

HalloWie EditText in editierbaren Text-Datei wie Notepad

Mein Problem ist, drehen, dass, wenn ich einen leeren Bildschirm mit ScrollView und EditText. Ich wollte meine App zu ermöglichen, Benutzer zu schreiben, was immer und wo immer er/sie will, ABER wenn ich die App lief, waren Sie nur in der Mitte eingeben dürfen. (Streckte ich die EditText den ganzen Bildschirm zu decken)

Hier ist mein Bildschirm:

enter image description here

Hier ist der Bildschirm, ich sollte/muss haben:

enter image description here

Hier ist der Code:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="onhar.personalnote.Writing_Table"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="1000dp"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="1000dp"> 



      </RelativeLayout> 

     </ScrollView> 

    </RelativeLayout> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@drawable/plusicon" /> 

    <include layout="@layout/content_writing__table" /> 

</android.support.design.widget.CoordinatorLayout> 

Ist das möglich?

+0

können Sie bitte Ihren Code teilen? –

+0

Überprüfen Sie es jetzt bitte – BusinessCash

Antwort

0

Wo Position ein int:

editText1.setSelection(position); 

editText1.setSelection(0); //You can set it as 0. 
1

In Ihrem XML müssen Sie android:gravity="top|start" auf EditText.

Wenn Sie es in Java-Code tun wollen, dann ist es: myEditText.setGravity(Gravity.TOP | Gravity.START);

0
EditText yourEt= (EditText) findViewById(R.id.yourEt); 
yourEt.requestFocus(); 
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.showSoftInput(yourEt, InputMethodManager.SHOW_IMPLICIT); 

// You can set focus of edittext only. 
// Please share your code. 
+0

Sie müssen Ihre Layouts ändern. –

0

Erste Sache ist, dass man nie feste Höhe verwenden sollte. Und beantworten Sie Ihre Anfrage, fügen Sie dieses Attribut android:fillViewport="true" zu Ihrem ScrollView hinzu. Fügen Sie auch android:gravity="top" zu EditText hinzu.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true"> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <EditText 
       android:id="@+id/edt" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="top" 
       android:hint="Hello" /> 
     </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 
Verwandte Themen