I am making a Keyboard which shows a popupWindow
of languages. In all device, I get perfect popupWindow
outside of keyboard but in only Android Pie, I can not show popupWindow
outside of the keyboard.
I want to show popup outside of keyboard's candidateView
when Bluetooth keyboard is connected.
I am using this code
setClippingEnabled(false);
showAtLocation(anchor, Gravity.NO_GRAVITY, x, y);
Does someone have any idea, what is the issue?
here is demo app - https://github.com/priyankagb/andoidpiepopupwindowdemo
see screenshots,
In Android Pie in which you can see a small line at the bottom which is popupWindow
for languages
Left is Below Pie, Right is Pie
android.widget.PopupWindow. This class represents a popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
To display the popup window above the view, you can use the showAsDropDown() function. With: v: View(Anchor)
Yes, I have solved my issue by changing my keyboard's layout file
I have added one dummy view above candidate view
like...
<androidx.constraintlayout.widget.ConstraintLayout 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">
<View
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/rlPredictionView" />
<RelativeLayout
android:id="@+id/rlPredictionView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/background_with_shadow_prediction_bar"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent">
...
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
than override this method in InputMethodService
class
@Override
public void onComputeInsets(InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets);
outInsets.visibleTopInsets = candidateView.getRelativeView().getTop();
outInsets.contentTopInsets = candidateView.getRelativeView().getTop();
}
dummy view above rlPredictionView
will set visibleTopInsets
of the keyboard and in this area, the popup will show
this dummy view will allow accessing background view on touch so this will not visible to the user
Reference - https://stackoverflow.com/a/53326786/10989990
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With