【问题标题】:Activity goes below status bar when soft keyboard opened软键盘打开时,活动低于状态栏
【发布时间】:2017-05-25 22:23:49
【问题描述】:

我正在开发 android 自定义键盘并遇到了这个问题。我正在使用候选人视图来显示建议。但在某些情况下,当我尝试在应用程序中使用键盘时,布局会在状态栏下方。 我附上了两张问题的图片。在带有红色矩形的两个屏幕截图中,我都标记了问题和绿色矩形键盘布局。 我已经对此进行了研究,发现如果没有以正确的方式创建候选视图,可能会导致这种情况,但我已经实现了候选视图,如示例中所示。This is an Image from Facebook messenger In this image keyboard is overlapping messengers edit text layout too.

这是我在 SoftKeyboard 中创建候选视图的代码 sn-ps。`

@Override public View onCreateCandidatesView() {
    mCandidateView = new CandidateView(this);
    mCandidateView.setService(this);
    mCandidateView.setOnTranslitModeChangedListener(this);
    return mCandidateView;
}`

我的键盘xml文件

<?xml version="1.0" encoding="utf-8"?>
<com.innorise.kitkeysarmenian.LatinKeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="50dp"
android:keyTextSize="18dp"
android:keyTextColor="#000"
android:background="@color/keyboardBackground"
android:keyPreviewLayout="@layout/preview"
android:popupLayout="@layout/keyboard_popup_layout"
android:drawingCacheQuality="high">

这是我的候选人查看 xml 文件`

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout      xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:padding="5dp"
    android:gravity="center">
    <android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:id="@+id/candidatesList"
    android:orientation="horizontal"
    app:layoutManager="android.support.v7.widget.LinearLayoutManager"
    android:layout_centerVertical="true"
    android:layout_toLeftOf="@+id/candidateSwitch"/>
    <TextView
    android:textSize="18sp"
    android:visibility="gone"
    android:text="Translit is off."
    android:gravity="center"
    android:id="@+id/translitModeisOff"
    android:layout_toLeftOf="@+id/candidateSwitch"
    android:layout_width="match_parent"
    android:layout_height="30dp" />
    <com.rm.rmswitch.RMSwitch
    android:id="@+id/candidateSwitch"
    app:switchDesign="slim"
    app:switchBkgCheckedColor="#4ed736"
    app:switchBkgNotCheckedColor="#cccccc"
    android:layout_centerVertical="true"
    android:layout_alignParentRight="true"
    app:switchToggleCheckedColor="#aca2a2"
    app:switchToggleNotCheckedColor="#aca2a2"
    android:layout_width="50dp"
    android:layout_height="35dp"/>
    </RelativeLayout>

【问题讨论】:

    标签: android keyboard android-softkeyboard soft-keyboard


    【解决方案1】:

    将此添加到您的清单中:

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

    【讨论】:

    • 我正在开发键盘,但问题是由键盘调用的
    猜你喜欢
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多