상세 컨텐츠

본문 제목

editText 사용한 글쓰기 레이아웃 설정

안드로이드+드론 제작

by 김일국 2016. 5. 14. 22:03

본문

이번에 안드로이드 앱 작업을 하게 되면서, 풀스크린으로 작업하게 되었습니다. 그런데, 풀스크린일때, 아래와 같은 레이아웃이 작동이 되지 않고, 화면이 밀려 올라가게 됩니다.

여러가지로 시도 하다가, 앱 초기 화면에서 로그인 전까지만

자바 단에서  풀스크린으로 설정하고(

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

), 로그인 이후에는 풀스크린을 사용하지 않게 변경해서 처리 하였습니다. 저처럼 않되는 부분때문에 고생하시지 말기 바랍니다.

적용한 파일은 2가지 입니다.

1. AndroidManifest.xml 파일 ( adjustResize: 화면을 키패드에 따라서 자동변경처리, stateVisible: 액티비티 시작시 키패드 자동으로 보이기옵션)

<activity

...
            android:windowSoftInputMode="stateVisible|adjustResize"

...

</activity>

2. 위 이미지 본문 레이아웃 파일 샘플 입니다.(핵심은 editText필드의 android:layout_weight="1" 옵션 지정입니다.)

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <EditText
            android:id="@+id/EditMessage"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="top"
            android:imeOptions="actionDone"
            android:inputType="textMultiLine|textFilter|textVisiblePassword|textNoSuggestions"
            android:maxLength="200"
            android:padding="5dp"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000"
            android:scrollbars="vertical"
            />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">

            <Button
                android:id="@+id/PostMessage"
                android:layout_width="0dp"
                android:layout_height="45dp"
                android:layout_marginRight="0.2dp"
                android:layout_weight="1"
                android:text="SubmitMessage"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />

            <Button
                android:id="@+id/CancelMessage"
                android:layout_width="0dp"
                android:layout_height="45dp"
                android:layout_marginRight="0.2dp"
                android:layout_weight="1"
                android:text="CancelMessage"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />

            <Button
                android:id="@+id/DeleteMessage"
                android:layout_width="0dp"
                android:layout_height="45dp"
                android:layout_weight="1"
                android:text="DeleteMessage"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout> 

Ps. 혹시 안드로이드스튜디오 작업화면에 android.support.v7.internal.app.windowdecoractionbar 에러 가 나오는 분들은

style.xml 파일의 테마를 아래 처럼 수정해 주세요

</style>
        <!-- Customize your theme here. -->
</style>


관련글 더보기

댓글 영역