IT Share you

편집 텍스트를 클릭 할 때 콘텐츠 푸시

shareyou 2020. 12. 14. 21:08
반응형

편집 텍스트를 클릭 할 때 콘텐츠 푸시


내 문제에 대한 해결책을 모든 곳에서 검색했지만 답을 찾을 수 없습니다. 여기에 문제가 있습니다.

다음과 같은 레이아웃이 있습니다.

이미지는 여기

이제 편집 텍스트 (검색 창)를 클릭하면 다음이 발생합니다.

이미지는 여기

The soft keyboard basically needs to push up the whole screens content so that the search bar is at the top and its listview is beneath it so that when the content is searched the results are displayed. I have tried setting android:windowSoftInputMode="adjustPan" to the Activity in the manifest but this did not work. I set a scroll view as the main container in the main layout that contains the fragments but that also did not work. I have tried adding the edit text(search bar) as a header to the list view but this also did not work. Every time the keyboard pushed up the edit text but covered the list view. Is there any way to make this work?


Actually if you want your entire layout pan up than you should use :

SOFT_INPUT_ADJUST_PAN

meaning:

getActivity().getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

this will keep the keyboard closed and when opened it'll push your entire activity up.


This can be used in Fragment Class to move the Edit text up and Scroll till end.

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

This will work for sure if your Fragment Activity theme is not in FullScreen.

Hope this will help!


This worked for me.

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

I faced a similar issue, the solution was simple.

If the theme in the activity is set as Fullscreen @android:style/Theme.Holo.NoActionBar.FullScreen, the keyboard was not pushing the contents up.

After I changed the activity to @android:style/Theme.Holo.NoActionBar, the keyboard is now pushing the activity contents up.


Try this

android:windowSoftInputMode="adjustResize"

Working for me.


Try android:windowSoftInputMode="adjustResize" in your manifest file.

You might need to do android:windowSoftInputMode="adjustResize|adjustPan"... I don't really have anything comparable to your setup to test on...

Your problem is becasue of this (from the docs for adjustPan, emphasis mine):

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

Given that, your list is being obscured becasue the EditText on top has the focus. The only thing I can currently think of is to move the EditText so it is below the list. Then when pushed up, your list should still be visible above the EditText.


This worked for me, for fragment, just declare it in Manifest with activity:

android:windowSoftInputMode="adjustPan"

Good Luck!


레이아웃이 자동으로 변경되는 솔루션을 찾을 수 없어서 해킹해야했습니다. 여기 에서 찾은 코드를 사용하여 키보드가 열렸을 때 감지했습니다. 키보드가 열릴 때 맨 위 두 조각을 숨기는 메서드를 호출하는 코드를 추가했습니다. 이것은 내가하고 싶었던 것이 아니라 작동합니다.


EditText로그인에 이것을 사용합니다 .

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

이 방법에 대한 몇 가지 참고 사항 :

thisgetActivity()항상 선호 되는 것은 아니기 때문에 문맥을 언급하고 있습니다.

.SOFT_INPUT_STATE_HIDDEN  //for default hidden state when activity loads

.SOFT_INPUT_STATE_VISIBLE //for auto open keyboard when activity loads 

매번 작동합니다!


여전히이 문제가 발생하는 경우 :

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:id="@+id/view"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent">

레이아웃에 추가 :

android:fitsSystemWindows="true"

이것이 당신의 문제를 해결하기를 바랍니다.

참고 URL : https://stackoverflow.com/questions/11292950/push-up-content-when-clicking-in-edit-text

반응형