如何prevent起重列表视图时,键盘上升 [英] How to prevent lifting listview when keyboard goes up
问题描述
这是code MainActivity Java和main.xml中
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);
}
当显示键盘,列表视图起重up.How至prevent这一点。
如果没有列表视图 - 一切正常(布局不上去)。
谢谢你。
When keyboard is shown, listview lifting up.How to prevent this. Without listview - all normal(layout NOT go up). Thank you.
更新问题与答案FOliveira。
遗憾的是我不能在我的真正的应用程序删除Java code(setSoftInputMode)。 Java的code必须是和列表视图布局必须上不去。尝试删除列表视图,你会看到布局不动绝对的,为什么用列表视图布局移动?根据这个条件,我如何prevent?
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?
推荐答案
我采用了android:windowSoftInputMode =stateVisible | adjustNothing,但这仅适用于API高出10(不幸)
I'm using android:windowSoftInputMode=" stateVisible|adjustNothing" , but this only for api higher 10(unfortunately).
更新:
增加的ListView这个属性之后:
机器人:focusableInTouchMode =假
机器人:isScrollContainer =假
我彻底解决了我的问题。
Update: After adding to listview this attributes: android:focusableInTouchMode="false" android:isScrollContainer="false" I'm completely solved my problem.
这篇关于如何prevent起重列表视图时,键盘上升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!