I am trying to set Popup window similar to the old Facebook comment section.
Rounded corner dialog box but I am facing a problem with size of dialog box
and showatlocation
of the Dialog box.
When I try this code on different mobile:
val display = windowManager.defaultDisplay
val size = Point()
display.getSize(size)
val popupWindow = PopupWindow(customView, size.x-30, size.y-300, true)
popupWindow.showAtLocation(linearLayout1, Gravity.CENTER, -3, 100)
popupWindow.setAnimationStyle(R.style.PopupAnimation)
Xml File :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/dialog_bg"
android:gravity="center"
android:orientation="vertical"
android:padding="10px">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<android.support.v7.widget.RecyclerView
android:id="@+id/popup_rcv"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/new_comment_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Please enter Comment" />
<Button
android:id="@+id/comment_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit" />
</LinearLayout>
</LinearLayout>
//Animation from Source
In one plus my animation also disable when I change .showAtLocation to other numbers
Output on Lenovo K8 Note:
In K8 note Location of Popup change if I change to another value.
Thank you in Advance.