作者 zhangji

popupWindow遮罩层还未处理完

package com.br_technology.securitytrain_master.expand
import android.content.res.Resources
/**
* createTime:2021/7/30 10:50
* auth:张继
* des:
*/
fun Int.dp2px(): Int {
val density = Resources.getSystem().displayMetrics.density
return (density * this + 0.5f).toInt()
}
fun Int.px2dp(): Int {
val density = Resources.getSystem().displayMetrics.density
return (this/density + 0.5f).toInt()
}
\ No newline at end of file
... ...
... ... @@ -8,6 +8,8 @@ import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.PopClassifyBinding
import com.br_technology.securitytrain_master.expand.addItemDecoration
import com.br_technology.securitytrain_master.expand.dp2px
import com.br_technology.securitytrain_master.expand.screenHeight
import com.br_technology.securitytrain_master.expand.screenWidth
import com.br_technology.securitytrain_master.ui.home.adapter.TextCourseTypeAdapter
import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
... ... @@ -26,9 +28,19 @@ class ClassifyPop(context: Activity) : PopupWindow(context) {
init {
contentView = binding.root
width = contentView.screenWidth()
height = height
setBackgroundDrawable(ContextCompat.getDrawable(context, R.color.white))
height = 252.dp2px()
setBackgroundDrawable(ContextCompat.getDrawable(context, android.R.color.transparent))
isOutsideTouchable = false
// val attributes = context.window.attributes
// attributes.alpha = 0.5f
// context.window.attributes = attributes
//
// setOnDismissListener {
// val attributes = context.window.attributes
// attributes.alpha = 1f
// context.window.attributes = attributes
// }
binding.apply {
courseType.addItemDecoration(3, 14)
... ... @@ -53,6 +65,12 @@ class ClassifyPop(context: Activity) : PopupWindow(context) {
})
courseType.adapter = textCourseTypeAdapter
textCourseTypeAdapter.addList(list)
complete.setOnClickListener {
dismiss()
}
}
}
... ...
... ... @@ -29,4 +29,5 @@
android:text="完成"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout>
\ No newline at end of file
... ...