您好我正在为Uni项目设计导航应用程序。当按钮出现在软键盘下方时,我遇到了问题。我使用LinearLayout作为框架。我经常搜索并尝试不同的技术,但似乎没什么用。
这是我的XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />
<requestFocus />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="vertical" >
<EditText
android:id="@+id/navi_searchfield1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Current location" >
</EditText>
<ListView
android:id="@+id/navi_listview1"
android:layout_width="fill_parent"
android:layout_height="0dp">
</ListView>
<EditText
android:id="@+id/navi_searchfield2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Destination" />
<ListView
android:id="@+id/navi_listview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<Button
android:id="@+id/start_navigation"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="@drawable/start"
android:textColor="#ffffff"
android:text="Start navigation" />
</LinearLayout>
答案 0 :(得分:1)
在AndroidManifest.xml中将android:windowSoftInputMode="adjustPan"
添加到您的活动中:
<activity
android:windowSoftInputMode="adjustPan"
.
.
.
</activity>
这将阻止SoftKeyboard移动您的按钮,为您提供如下输出:
即使通过在屏幕上滚动显示键盘,也可以使用该按钮。但我认为您可能无法在按钮上方显示键盘,因为我使用SoftKeyboard并使用:
android:layout_alignParentBottom="true"
因此,您只能保护您的布局不被SoftKeyboard推送。