我在Android棒棒糖上遇到问题,当软键盘出现时,屏幕无法调整大小。
这是我所做的一项活动的明显介绍示例:
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
是否有新的东西被添加,我们必须考虑到Android 5.0? scrollview在android<上工作正常5.0。
答案 0 :(得分:4)
问题是它没有使用半透明状态栏而且我不得不设置
android:fitsSystemWindows="true"
在我的主要布局中
答案 1 :(得分:3)
对于那些即使在ScrollView中使用android:fitsSystemWindows="true"
仍有此问题的人。
我找到了解决问题的方法:
fragment.xml
格式使用RelativeLayour并将android:fitsSystemWindows="true"
放入其中。 ScrollView用作RelativeLayour的子项。 <RelativeLayout android:fitsSystemWindows="true">
<ScrollView/>
</RelativeLayout>
这两个选项都应与android:windowSoftInputMode="adjustResize"
一起使用,适用于带有<item name="android:windowTranslucentStatus">true</item>
标记的Android 5。
`
答案 2 :(得分:-1)
我尝试过的任何事情都没有效果,而且我已经完成了不同Manifest设置等各种可能的组合,但无济于事。
它有点hacky但它对我来说很漂亮:
((RelativeLayout) findViewById(R.id.rootLayout)).addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
scrollToLatest(); // Do your scrolling!
}
});