Untitled
unknown
plain_text
2 years ago
1.9 kB
23
Indexable
private fun showGpsAccuracy(btn: LinearLayout) {
// Inflate the custom layout for the popup content
val inflater = LayoutInflater.from(this)
val customView = inflater.inflate(R.layout.gpsdetails, null)
horizontalTxtv = customView.findViewById<TextView>(R.id.horizontalgps)
verticalTxtv = customView.findViewById<TextView>(R.id.verticalgps)
val closepopup = customView.findViewById<LinearLayout>(R.id.closeicon)
// val imgnaem = customView.findViewById<TextView>(R.id.imagename)
val decimalval = DecimalFormat("#.##")
horizontalTxtv.setText("Horizontal Accuracy "+decimalval.format(horizontalVal) +"m")
verticalTxtv.setText("Vertical Accuracy "+decimalval.format(verticalVal)+"m")
// Create the PopupWindow
popupGpsW = NonDismissiblePopupWindow(customView, ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
// Calculate the (x, y) position relative to the button
val buttonLocation = IntArray(2)
btn.getLocationInWindow(buttonLocation)
val xPosition = buttonLocation[0] // x-coordinate
val yPosition = buttonLocation[1] - 60 // y-coordinate
// Show the PopupWindow at the specified (x, y) position
popupGpsW.isOutsideTouchable = false
popupGpsW.isFocusable = true
popupGpsW.showAtLocation(btn, Gravity.NO_GRAVITY, xPosition, yPosition)
popupGpsW.setOnDismissListener {
gpspopupbtn.visibility = View.VISIBLE
// popupWindow.showAtLocation(btn, Gravity.NO_GRAVITY, xPosition, yPosition)
}
closepopup.setOnClickListener {
gpspopupbtn.visibility = View.VISIBLE
popupGpsW.dismiss()
}
}Editor is loading...