如何使弹出视图内的线性布局响应?

How to make linear layout inside pop up view responsive?

我想做的是显示响应式弹出视图。我现在所拥有的是弹出视图调整了原始线性布局的大小,并且在某些设备上显示非常糟糕。

这是线性布局 xml 的样子

layout.xml

当我运行它时,它是这样显示的

popupView

这是弹出视图代码:

private fun setUpModalProduct() {
        inventoryMovementPopUpView = layoutInflater.inflate(R.layout.modal_inventory_movement,
                null) // inflating popup layout
    val width = (resources.displayMetrics.widthPixels * 0.40).toInt() // 0.90 = 90% of width size
    val height = (resources.displayMetrics.heightPixels * 1).toInt() // 0.90 = 90% of hight size

    inventoryMovementPopUp = PopupWindow(inventoryMovementPopUpView,
            width,  //width value
            height,  //height value
            true) // Creation of popup

    inventoryMovementPopUp!!.animationStyle = android.R.style.Animation_Dialog
    inventoryMovementPopUp!!.showAtLocation(inventoryMovementPopUpView, Gravity.CENTER, 0, 0)

    inventoryMovementPopUp!!.isOutsideTouchable = false
    inventoryMovementPopUp!!.isFocusable = false
}

任何帮助或建议都将非常有用,谢谢!

尝试

 val width = 600 //LinearLayout.LayoutParams.WRAP_CONTENT
 val height = LinearLayout.LayoutParams.MATCH_PARENT

在你的布局上 xml parent

android:layout_width="wrap_content"
android:layout_height="match_parent">