android에서 adjustResize와 adjustPan의 차이점은 무엇입니까?
소프트 키보드 가 나타날 때 UI 구성 요소의 크기를 조정하는 데 사용되는 코드를 작성하려고했습니다 . 내가 사용하는 경우 adjustResize를, 그것은 UI 구성 요소 크기의 입술 동시에 adjustPan는 나에게 같은 출력을했다. 차이점과 각 구성 요소를 언제 사용해야하는지 알고 싶습니다. UI 크기를 조정하기에 적합한 것은 어느 것입니까 (adjustPan 또는 adjustResize)?
내 XML은 다음과 같습니다.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<EditText
android:id="@+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:ems="10"
android:inputType="textPersonName" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:text="My Button" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
그리고 매니페스트 파일 :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.adjustscroll"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.adjustscroll.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan|adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
로부터 안드로이드 개발자 사이트 링크
"adjustResize"
활동의 기본 창은 항상 화면의 소프트 키보드를위한 공간을 만들기 위해 크기가 조정됩니다.
"adjustPan"
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
according to your comment, use following in your activity manifest
<activity android:windowSoftInputMode="adjustResize"> </activity>
adjustResize = resize the page content
adjustPan = move page content without resizing page content
As doc says also keep in mind the correct value combination:
The setting must be one of the values listed in the following table, or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group — multiple "state..." values, for example — has undefined results. Individual values are separated by a vertical bar (|). For example:
<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >
You can use android:windowSoftInputMode="stateAlwaysHidden|adjustResize" in AndroidManifest.xml for your current activity, and use android:fitsSystemWindows="true" in styles or rootLayout.
'Programing' 카테고리의 다른 글
| 클래스 이름에 "this"사용 (0) | 2020.07.27 |
|---|---|
| ggplot을 사용하여 축의 숫자 형식을 어떻게 변경합니까? (0) | 2020.07.27 |
| 자바; (0) | 2020.07.27 |
| 반복하는 동안 HashSet에서 요소 제거 (0) | 2020.07.27 |
| 해시의 값을 기준으로 해시 배열을 어떻게 정렬합니까? (0) | 2020.07.27 |