소프트 키보드 팝업시 페이지 스크롤
나는이 <ScrollView>
레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/input_one"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_two"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_three"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<Button
android:id="@+id/ok_btn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/ok_str" />
</LinearLayout>
</ScrollView>
위에서 볼 수 있듯이 간단한 레이아웃은 3 개의 입력 필드와 "확인"버튼으로 구성됩니다.
위의 레이아웃으로 앱을 실행합니다. 첫 번째 입력 필드 ( @+id/input_one
)를 탭 하면 소프트 키보드가 화면 하단에서 팝업되고 세 번째 입력 필드와 "확인"버튼 이 숨겨 집니다.
을 사용했기 때문에 소프트 키보드에 가려진<ScrollView>
세 번째 입력 필드와 "확인"버튼을보기 위해 페이지를 위로 스크롤 할 수 있다고 생각 했지만 페이지를 스크롤 할 수 없습니다 . 왜? 그것을 제거하는 방법? 기본적으로 소프트 키보드가 튀어 나와도 모든 입력 필드와 "확인"버튼을보고 싶습니다.
I fixed the problem by defining the following attribute in <activity>
of AndroidManifest.xml
android:windowSoftInputMode="stateVisible|adjustResize"
Ok, I have searched several hours now to find the problem, and I found it.
None of the changes like fillViewport="true"
or android:windowSoftInputMode="adjustResize"
helped me.
I use Android 4.4 and this is the big mistake:
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
Somehow, the Fullscreen themes prevent the ScrollViews from scrolling when the SoftKeyboard is visible.
At the moment, I ended up using this instead:
android:theme="@android:style/Theme.Black.NoTitleBar
I don't know how to get rid of the top system bar with time and battery display, but at least I got the problem.
Hope this helps others who have the same problem.
EDIT: I got a little workaround for my case, so I posted it here:
I am not sure if this will work for you, but it will definitely help you in understanding, and clear some things up.
EDIT2: Here is another good topic that will help you to go in the right direction or even solve your problem.
For me the only thing that works is put in the activity in the manifest this atribute:
android:windowSoftInputMode="stateHidden|adjustPan"
To not show the keyboard when opening the activity and don't overlap the bottom of the view.
put this inside your Manifest like this in No fullscreen Mode
android:windowSoftInputMode="stateVisible|adjustPan"
in your manifest
<activity
android:windowSoftInputMode="stateVisible|adjustPan"
android:name="com.example.patronusgps.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
in your Manifest
define windowSoftInputMode
property <activity android:name=".MyActivity" android:windowSoftInputMode="adjustNothing">
Add below line of code in Android Manifest file under activity tag
android:windowSoftInputMode="adjustResize"
check out this.
<activity android:name=".Calculator" android:windowSoftInputMode="stateHidden|adjustResize" android:theme="@android:style/Theme.Black.NoTitleBar"></activity>
This only worked for me:
android:windowSoftInputMode="adjustPan"
You can try using the following code to solve your problem:
<activity
android:name=".DonateNow"
android:label="@string/title_activity_donate_now"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:windowSoftInputMode="stateVisible|adjustPan">
</activity>
Also if you want to do that programmatically just add the below line to the onCreate of the activity.
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE |
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE );
참고URL : https://stackoverflow.com/questions/9989130/page-scroll-when-soft-keyboard-popped-up
'program tip' 카테고리의 다른 글
디렉토리를 삭제하는 것보다 iPhone Simulator 캐시를 지우는 더 빠르고 더 좋은 방법이 있습니까? (0) | 2020.09.09 |
---|---|
특정 파일 확장자에 대한 Android 인 텐트 필터? (0) | 2020.09.09 |
ADO.NET에서 출력 매개 변수 값 가져 오기 (0) | 2020.09.09 |
쉬운 디버깅을 위해 Rails에서 객체의 내용을 어떻게 인쇄합니까? (0) | 2020.09.09 |
기억과 관련하여 경기장이라는 용어의 의미는 무엇입니까? (0) | 2020.09.08 |