2016-10-18 3 views
0

안녕메모장과 같은 편집 가능한 텍스트 파일로 글고을 설정하는 방법

내 문제가있다 그 나는 ScrollViewEditText 빈 화면이있을 때. 내 앱이 사용자가 지금까지 무엇을 쓸 수있게하고 싶었고, 앱을 실행했을 때 BUT 중간에 입력 만 허용되었습니다. 내가/필요하도록한다

여기 enter image description here

화면입니다 : 여기

enter image description here

여기

내 화면입니다 (I 전체 화면을 커버하기 글고을 뻗어) 코드 :

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

이것이 가능합니까? 위치는 int이며

+0

코드를 공유해주십시오. –

+0

지금 확인하십시오 – BusinessCash

답변

0

: 당신의 XML에서

editText1.setSelection(position); 

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

당신은 당신의 EditText에 android:gravity="top|start"이 필요합니다. 당신은 자바 코드에서 그것을하고 싶은 경우

는 다음입니다 : 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

레이아웃을 변경해야합니다. –

0

우선 당신이 고정 높이를 사용하지 않을해야한다는 것입니다. 그리고 귀하의 질문에 대한 답변은이 속성을 에 추가하십시오 (android:fillViewport="true"). 또한 EditText에 android:gravity="top"을 추가하십시오.

<?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> 
관련 문제