문제

This is code MainActivity java and main.xml

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout"
android:gravity="center"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#75F575">

<LinearLayout
    android:clickable="true"
    android:layout_gravity="center"
    android:orientation="vertical"
    android:layout_width="250dp"
    android:layout_height="100dp"
    android:background="#C69817"
    android:id="@+id/secondLayout">

    <ListView
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/mainListView1"/>

</LinearLayout>

</LinearLayout>

Java:

      public void onCreate(Bundle       savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);              
            ListView lv = (ListView) findViewById(R.id.mainListView1);
            ArrayAdapter<String> a = new ArrayAdapter<String>(this, 
                    android.R.layout.simple_list_item_1 ,
                    new String [] {"item1","item2"});
            lv.setAdapter(a);
            getWindow().setSoftInputMode(
                    WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}   

When keyboard is shown, listview lifting up.How to prevent this. Without listview - all normal(layout NOT go up). Thank you.

UPDATE QUESTION with answer to FOliveira. Unfortunately i can't remove java code (setSoftInputMode) in my real app. Java code must be and layout with listview must NOT GO UP. Try to remove listview, and you will see the layout not moving absolutely, Why layout with listview is moving? How prevent this according my conditions?

도움이 되었습니까?

해결책 2

I'm using android:windowSoftInputMode="stateVisible|adjustNothing" , but this only for API higher 10(unfortunately).

Update: After adding to listview this attributes:

android:focusableInTouchMode="false"
android:isScrollContainer="false"

I'm completely solved my problem.

다른 팁

You need to add android:windowSoftInputMode="adjustPan" to your tag in the AndroidManifest.xml file.

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.

If this option does not fit your needs, you can allways check Android documention about soft input mode

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top