我正在开发Android自定义键盘并面临这个问题。我正在使用候选人视图来显示建议。但在某些情况下,当我尝试在应用程序中使用键盘时布局正在状态栏下。 我附上了两张问题图片。在带有红色矩形的两个屏幕截图中,我都标记了问题,并使用绿色矩形键盘布局。 我已经对此进行了研究,发现如果Candidate视图没有以正确的方式创建,可能会导致它,但我已经实现了候选视图,如示例所示。This is an Image from Facebook messenger In this image keyboard is overlapping messengers edit text layout too.
以下是我在SoftKeyboard上创建候选人视图的代码片段。
@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>
答案 0 :(得分:0)
将此添加到您的清单中:
<activity
android:name="activity.name"
android:windowSoftInputMode="adjustPan|adjustResize"/>