【问题标题】:Android : Showing keyboard moves my components up, i want to hide them insteadAndroid:显示键盘将我的组件向上移动,我想隐藏它们
【发布时间】:2010-11-29 06:41:16
【问题描述】:

我添加了一个带有一些按钮的 LinearLayOut 我的屏幕是它自己的 RelativeLayOut

这是线性布局管理器的代码

<LinearLayout
    android:orientation="horizontal"
    android:gravity="bottom"
    android:layout_alignParentBottom="true"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:id="@+id/Footer"
    android:layout_marginBottom="5dp">

问题来了:

顶部有一个 EditText 组件,它会在屏幕上弹出一个软键盘,并将我的页脚管理器带到键盘顶部,最终粉碎我的整个 UI。

确切的解决方案是什么?

附:我已经一一删除了android:gravity="bottom"android:layout_alignParentBottom="true",但运气不好我没有得到想要的结果。

谢谢

【问题讨论】:

  • 经过一番挖掘后,我知道了这条线android:windowSoftInputMode="adjustPan",但我不知道在哪里添加它?在清单中还是在屏幕的主要相对布局中?
  • 不移除 android:gravity="bottom" 和 android:layout_alignParentBottom="true" 有没有可能?

标签: android android-layout


【解决方案1】:

android:windowSoftInputMode="adjustPan" 添加到 manifest - 到相应的活动中:

  <activity android:name="MyActivity"
    ...
    android:windowSoftInputMode="adjustPan"
    ...
  </activity>

【讨论】:

【解决方案2】:

你可能想要

<activity
     ...
   android:windowSoftInputMode="adjustNothing"> 
</activity>

这将防止在显示软键盘时发生任何布局更改。

这可能有些混乱,因为它目前在 http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft 的文档中缺失

【讨论】:

  • 这可以节省我的时间!谢谢!
  • 不明白为什么这有更少的选票。这是一个有效的方法,谢谢!
  • 应该就是这个!它对我有用,而其他人没有!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-13
  • 1970-01-01
  • 2020-12-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多