質問

いくつかの要素RelativeViewにわせ下の属性セットの場合、ソフトキーボード付属の要素によって隠されたソフトキーボード。

してほしいと思い移動するようにが多く含まれている場合は画面スペースでの上に記載されているキーボード、または上記のセクションのキーボードスクロール可能なので、ユーザーだったのです。

そのアイデアなどについて説明す。

役に立ちましたか?

解決

はい、上のこの記事をチェックアウトソフトキーボードが表示されてどのようなフレームワークのハンドル説明Androidの開発者向けサイトでます。

android:windowSoftInputMode属性ごとの活動ベースで何が起こるかを指定するために使用することができます:レイアウトのサイズが変更されているかどうか、それがスクロールなど

か。

他のヒント

またonCreate()方法でこのコードを使用することができます:

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

あなたの活動のためのAndroidManifest.xmlに追加します。

android:windowSoftInputMode="adjustPan|adjustResize"

変更に活動のマニフェストファイルのように

windowSoftInputMode="adjustResize"

または

の変更 onCreate() 法の活動のようにクラス

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
スクロールビューの内部を構成されて私は私のレイアウトで直面していた

同様の問題。 私はのEditText、コピー/切り取りでテキストを選択しようとするたびに/貼り付けアクションバーは、そのようなことはないではないリサイズレイアウト

のようにコードの下で上に移動します
android:windowSoftInputMode="adjustPan"

以下のようにこれを変更することによって

1)のAndroidManifest.xml

android:windowSoftInputMode="stateVisible|adjustResize"

2)style.xmlファイル、活動のスタイルで

<item name="android:windowActionBarOverlay">true</item>

これは、働いていた。!!!!!!!!!!!!

でのAndroidManifest.xmlが、設定することを忘れないでください。

 android:windowSoftInputMode="adjustResize"

とScrollView、セット内部のRelativeLayoutのために

 android:layout_gravity="center" or android:layout_gravity="bottom" 

それはなります大丈夫

ライン以下のOnCreate関数Methodeのインサートにおける活性について

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

とそののonCreateメソッド内のフラグメントのための

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

が3段にスクロール画面です。

  1. 書マニフェストファイルのための活動:

android:windowSoftInputMode="adjustResize"

  1. 以下の項目を追加ラインoncreate()メソッドの活動

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

  1. その場全体を見"Scrollview"XMLファイルのように:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:background="@drawable/bg"
    android:layout_height="match_parent" 
    > 
    <RelativeLayout
         android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center" >
        <TextView />
         .........
        <TextView />
        <EditText >
            <requestFocus />
        </EditText>
        <Button />
    </RelativeLayout>
 </ScrollView>

P.S.たくさんのメandroid:layout_gravity="center"親/ルンルン気分/親子に対す。

私はそれが動作ディエゴ・ラミレスの方法を試してみました。 AndroidManifestでます:

    <activity
        android:name=".MainActivity"
        android:windowSoftInputMode="stateHidden|adjustResize">
        ...
    </activity>
activity_main.xmlで

<LinearLayout ...
    android:orientation="vertical">

<Space
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1" />

<EditText
    android:id="@+id/edName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="@string/first_name"
    android:inputType="textPersonName" />

<EditText ...>
...
</LinearLayout>

私はそれはあなたとかなり同じだというのが私の問題への解決策を見つけています。

私はキーボードなしでフルスクリーンで分離し、キーボードが表示されたとき、彼らはなりますそれらを保つために必要なので、

まず、私は、2つの要素、2のEditTextと1つのボタンが含まれていますウィッヒImageViewのとのLinearLayoutでのLinearLayoutを持っています近います。

だから私は、私は1が互いを形成する分離、私の見解を維持させる0dpと重量1でheight属性とそれらの間のビューを追加しました。そして、するとき、キーボードappers、彼らは修正高さを持っていないとして、彼らは単にサイズを変更し、側面をキープます。

出来上がり!キーボードが存在しているか、いないときのレイアウトのサイズ変更と私の意見の間の距離は同じである。

ここでは、完全なマニフェストコードは

<activity
        android:name=".activities.MainActivity"
        android:windowSoftInputMode="adjustResize"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
あなたが断片的にあるならば、あなたがあなたの活動にあなたのonCreateに以下のコードを追加する必要があり、それは

私のために問題を解決します
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
マニフェストファイルに線の下に追加します。それは動作します。

<activity name="MainActivity"
    android:windowSoftInputMode="stateVisible|adjustResize">
    ...
</activity>
さてさて、これは非常に遅く、しかし私はあなたのエディットテキストの下にリストビューを追加した場合、その後キーボードがリストビューを移動せずにその下のEditTextすべてのレイアウトを移動することを発見しましたです。

<EditText
android:id="@+id/et"
android:layout_height="match_parent"
android:layout_width="match_parent"



/>

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"//can make as 1dp
    android:layout_below="@+id/et" // set to below editext
    android:id="@+id/view"
    >
**<any layout**

これは私のために働いた唯一のソリューションです。

Here is the solution for this fix
- android:windowSoftInputMode="adjustResize" in Manifest File
- Make a class "CommentKeyBoardFix.Java" and copy and paste the below code.

public class CommentKeyBoardFix
{
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private Rect contentAreaOfWindowBounds = new Rect();

public CommentKeyBoardFix(Activity activity)
{
    FrameLayout content = activity.findViewById(android.R.id.content);
    mChildOfContent = content.getChildAt(0);
    mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(this::possiblyResizeChildOfContent);
    frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}

private void possiblyResizeChildOfContent()
{
    int usableHeightNow = computeUsableHeight();
    if (usableHeightNow != usableHeightPrevious)
    {
        int heightDifference = 0;
        if (heightDifference > (usableHeightNow /4))
        {
            // keyboard probably just became visible
            frameLayoutParams.height = usableHeightNow - heightDifference;
        }
        else
        {
            // keyboard probably just became hidden
            frameLayoutParams.height = usableHeightNow;
        }
        mChildOfContent.layout(contentAreaOfWindowBounds.left, contentAreaOfWindowBounds.top, contentAreaOfWindowBounds.right, contentAreaOfWindowBounds.bottom);
        mChildOfContent.requestLayout();
        usableHeightPrevious = usableHeightNow;
    }
}

private int computeUsableHeight()
{
    mChildOfContent.getWindowVisibleDisplayFrame(contentAreaOfWindowBounds);
    return contentAreaOfWindowBounds.height();
}
}

And then call this class in your Activity or Fragment
setContentView(R.layout.your_comments_layout)
CommentKeyBoardFix(this) ---> For Kotlin
or
new CommentKeyBoardFix(this) ---> For Java

私はちょうど、トップレベルのレイアウトに次の行を追加し、すべてが働いてます:

android:fitsSystemWindows="true"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top