마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

키보드가 활성화 상태일 때 EditText가 짤립니다. [closed]

0 추천

안녕하세요.

커뮤니티 전용 IRC 앱을 만들고 있습니다.

개발 중 키보드 관련 이슈가 있어 질문드립니다.

키보드가 활성화 상태일 때 EditText가 짤리는 이슈입니다.

 

EditText를 선택하기 전(키보드가 활성화 되기 전) 상태 입니다.

 

EditText를선택하여 키보드가 활성화 된 상태 입니다.

 

EditText의 hint의 글자가 짤린것을 볼 수 있습니다.

제 생각으로는 ircBottomLayout의 layout_weight가 0.08이기 때문에 키보드가 활성화 되고, 전체 레이아웃 크기가 축소되면서 EditText의 height도 같이 Resize되는걸로 보입니다. 

실제로 AndroidManifest.xml에 해당 Activity 옵션 

android:windowSoftInputMode="adjustPan"

을 추가하면 아래와 같이 화면이 위로 밀려나면서 글씨가 짤리지 않습니다. (Resize가 발생하지 않음)

 

아래는 사용한 레이아웃 입니다.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1"
    >
    <LinearLayout
        android:id="@+id/ircTopLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.92"
        android:weightSum="1"
        android:orientation="horizontal"
        >
    <TextView
        android:id="@+id/ircMessage"
        android:layout_height="match_parent"
        android:layout_width="0dp"
        android:layout_weight="0.8"
        android:scrollbars = "horizontal"
        android:gravity="bottom"
        android:autoLink="all"
        >
    </TextView>
    <ListView
        android:id="@+id/ircUserList"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:layout_weight="0.2"
        />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/ircBottomLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.08"
        android:gravity="bottom"
        android:focusable="true"
        android:focusableInTouchMode="true"
        >
    <EditText
        android:id="@+id/Edit1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:hint="대화 내용을 입력해 주세요."
        />
    </LinearLayout>
</LinearLayout>

 

화면이 위로 밀리지 않고, 키보드가 활성화 상태일 때 EditText가 짤리지 않는 방법이 있을까요?

혹시 아시면 답변 부탁드립니다.

감사합니다.

질문을 종료한 이유: 해결하였습니다.
webgori 님이 2015년 9월 22일 질문
2015년 9월 23일 closed

1개의 답변

0 추천
 
채택된 답변
EditText가 들어있는 부분에 weight를 주지 말고 wrap_content로 하면 됩니다. 보니 ircBottomLayout id의 LinearLayout에 weight가 들어있는데 ircBottomLayout 가 있어야할 이유가 없어보이네요.
회색 (21,340 포인트) 님이 2015년 9월 22일 답변
답변 감사합니다.
말씀하신 방법으로 해보았습니다.
화면이 위로 밀리지 않고, EditText가 짤리지도 않습니다만 EditText 밑에 최상위 LinearLayout의 빈공간이 보이네요.
EditText 밑에 남는 공간이 없이 깔끔하게 보이게 하고 싶습니다.

회색님 답변 참고하여 이리저리 해보다가 해결하였습니다.
다만, ircTopLayout의 layout_weight값을 왜 0이상으로 주면 해결되는지는 모르겠네요.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="bottom"
    >
    <LinearLayout
        android:id="@+id/ircTopLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.1"
        android:weightSum="1"
        android:orientation="horizontal"
        >
    <TextView
        android:id="@+id/ircMessage"
        android:layout_height="match_parent"
        android:layout_width="0dp"
        android:layout_weight="0.8"
        android:scrollbars = "horizontal"
        android:gravity="bottom"
        android:autoLink="all"
        >
    </TextView>
    <ListView
        android:id="@+id/ircUserList"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:layout_weight="0.2"
        />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/ircBottomLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_gravity="bottom"
        >
    <EditText
        android:id="@+id/Edit1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:hint="대화 내용을 입력해 주세요."
        />
    </LinearLayout>
</LinearLayout>
...