【问题标题】:View is not displaying when keyboard is displaying?键盘显示时视图不显示?
【发布时间】:2023-03-09 02:53:01
【问题描述】:

我的应用有登录屏幕,它支持横向和纵向。它工作正常。我的问题是在纵向模式下单击编辑文本时显示键盘很好。画面如下:

但是横向模式看起来不像纵向模式。屏幕看起来像横向模式:

这是我的清单代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.activities"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    
    <!-- Allow to connect with internet -->
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/launcher_icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        
        <!--  Add Google Map Library -->
        <uses-library android:name="com.google.android.maps" />
       
        <activity
            android:name=".SplashActivity"
            android:label="@string/app_name"
            android:noHistory="true" android:theme="@style/generalNoTitle">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".LoginActivity" android:theme="@style/generalNoTitle" android:configChanges="keyboardHidden|orientation" />
        <activity android:name=".MenuActivity" android:theme="@style/generalNoTitle" />
        <activity android:name=".RegularReportsActivity" android:theme="@style/generalNoTitle" android:screenOrientation="landscape"/>
        <activity android:name=".StageMaleAndFemaleActivity" android:theme="@style/generalNoTitle" android:screenOrientation="landscape"/>
        <activity android:name=".MapViewActivity" android:theme="@style/generalNoTitle" android:screenOrientation="landscape"/>
        <activity android:name=".ReportViewActivity" android:theme="@style/generalNoTitle" android:screenOrientation="landscape"/>
    </application>

</manifest>

如何在横向模式下像纵向模式一样显示?还有,谁能指导我?

【问题讨论】:

  • 这是自定义键盘吗?
  • 在滚动视图中添加您的所有视图,并 android:configChanges="keyboardHidden|orientation" 将此添加到清单中的活动标签中,这将解决您的问题
  • @lok​​oko 没有默认键盘

标签: android keyboard android-keypad


【解决方案1】:

只需添加 android:imeOptions="flagNoExtractUi" 即可编辑文本

【讨论】:

    【解决方案2】:

    您能否将以下内容添加到清单文件中:

    android:configChanges="orientation|keyboardHidden"
    android:windowSoftInputMode="stateHidden"
    

    还可以在 scrollView 下添加附上您的登录页面。像

    【讨论】:

    • 您是否将布局包含在滚动视图中?
    • 是的,我添加了滚动视图
    • 试试这个:android:configChanges="orientation|screenSize"
    • 你能分享你的清单吗?你试过 android:configChanges="keyboardHidden|orientation" 吗?这应该有效。基本上,当您更改方向时,它会重新创建并再次调用 onCreate。另外,两个屏幕的布局是否相同?
    【解决方案3】:

    用包围你的布局

    在 androidmanifest 中添加这一行

    android:windowSoftInputMode="stateHidden|adjustResize|adjustPan"

    【讨论】:

    • @chiru,为什么在横向模式下需要纵向键盘。默认情况下,android 操作系统会为纵向和横向模式激活单独的键盘以进行用户交互。你将强制改变这一点。它行为不端您的应用程序。
    【解决方案4】:

    我认为您没有为横向模式实现应用登录屏幕。所以,它显示的是默认视图。

    res 文件夹中创建一个子文件夹 layout-land 也为横向实现 UI

    【讨论】:

    • 横向模式实现是什么意思?
    猜你喜欢
    • 2011-09-26
    • 2015-10-19
    • 2015-05-31
    • 1970-01-01
    • 1970-01-01
    • 2016-01-08
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多