【问题标题】:Android: Layout collapse when soft keypad comes and action bar is also movingAndroid:当软键盘出现并且操作栏也在移动时布局崩溃
【发布时间】:2015-08-24 08:12:05
【问题描述】:

我创建了带有滚动视图的注册屏幕,其中包含编辑文本和操作栏。当键盘打开布局 getshrink 时,我在 androidmanifest 文件中使用了 adjustPan 和 adjustResize。

AndroidManifest.xml

<activity android:name=".UserRegistration"
        android:windowSoftInputMode="adjustPan|adjustResize">
</activity>

我在滚动视图中使用了 android:isScrollContainer="false"。

UserRegistration.xml

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:isScrollContainer="false">
  ....
</ScrollView>


EditText edtPhoneNo = (EditText)findViewById(R.id.mobileno);
edtPhoneNo.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View arg0, MotionEvent arg1) {
            edtPhoneNo.bringToFront();
            edtPhoneNo.invalidate();
            return false;
        }
});

小键盘打开时操作栏不应移动,布局不应折叠。

谁能帮我解决这个问题

提前致谢

【问题讨论】:

    标签: android android-actionbar android-scrollview android-keypad


    【解决方案1】:

    这对我有用:

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

    【讨论】:

    • 您好,感谢您的回复,它的工作正常,但是当键盘打开时,edittext 不可见。
    • editText.bringToFront(); editText.invalidate();应该这样做。
    • 编辑你的问题并将代码放在你点击editText的地方和你的键盘出现的地方。
    • EditText edtPhoneNo = (EditText)findViewById(R.id.mobileno); edtPhoneNo.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View arg0, MotionEvent arg1) { edtPhoneNo.bringToFront(); edtPhoneNo.invalidate() return false; } });
    • @Kamal 如果你说它不起作用,你为什么要接受答案?
    【解决方案2】:

    根据我对你的英语的理解,在你的 AndroidManifest.xml 中试试这个

    <activity android:name=".UserRegistration"
            android:windowSoftInputMode="adjustResize">
    </activity>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 2011-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多