2

При появлении клавиатуры поднимается layout с listview...

Как отменить поднятие lauout-a ?

Вот 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">

<Button
        android:layout_height="wrap_content"
        android:text="Button"
        android:layout_width="wrap_content"
        android:onClick="onClick"
        android:id="@+id/mainButton1"/>

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

 </LinearLayout>
</LinearLayout>

Клава вызывается напр. так:

InputMethodManager imm=(InputMethodManager)getSystemService (Context.INPUT_METHOD_SERVICE);
                        if (imm != null)
                        {
                            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                        }

Вот весь код:

@Override
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);
}

public void onClick(View v){
    InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null)
    {
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    } 
    }

Но чертовый listview все равно двигается вгору , ему все равно что нет никаких эдитбоксов и так далее...

Это не помогает полностью : android:windowSoftInputMode="adjustPan" Листвью все равно частично двигается, да и костылевое это решение. Почему то layout считает, что если появляется клавиатура, то нужно обязательно двигать лисвью. Вот как бы это отменить в самом листвью, может быть ?

1 ответ 1

4

Наконец то нашел решение - нужно добавить в listview такие атрибуты:

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

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.