相关疑难解决方法(0)

何时使用Android PopupWindow vs Dialog

我不清楚何时使用PopupWindow vs Dialog.任何见解都会非常感激.谢谢.

comparison android dialog use-case popupwindow

28
推荐指数
2
解决办法
9138
查看次数

弹出窗口有问题

我试图设置类似于旧的Facebook评论部分的弹出窗口.

圆角对话框,但我现在面临一个问题,size of dialog boxshowatlocation对话框.

当我在不同的手机上尝试此代码时:

        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的动画

Oneplus 6T输出: 一加

在一个加号我的动画也禁用当我将.showAtLocation更改为其他数字

联想K8输出注:

K8注意

在K8中,如果我更改为另一个值,则弹出窗口的位置会发生变化.

先感谢您.

android popupwindow kotlin

6
推荐指数
1
解决办法
293
查看次数

标签 统计

android ×2

popupwindow ×2

comparison ×1

dialog ×1

kotlin ×1

use-case ×1