我不清楚何时使用PopupWindow vs Dialog.任何见解都会非常感激.谢谢.
我试图设置类似于旧的Facebook评论部分的弹出窗口.
圆角对话框,但我现在面临一个问题,size of dialog box和showatlocation对话框.
当我在不同的手机上尝试此代码时:
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)
Run Code Online (Sandbox Code Playgroud)
Xml文件:
<?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>
Run Code Online (Sandbox Code Playgroud)
//来自Source的动画
在一个加号我的动画也禁用当我将.showAtLocation更改为其他数字
联想K8输出注:
在K8中,如果我更改为另一个值,则弹出窗口的位置会发生变化.
先感谢您.