From 8e33880dbc301d25f077b4d0250a06fc1f771103 Mon Sep 17 00:00:00 2001 From: tateisu Date: Fri, 13 Jan 2023 04:09:24 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E6=95=B4=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../itemviewholder/StatusButtonsPopup.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/StatusButtonsPopup.kt b/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/StatusButtonsPopup.kt index 57eb9ff0..a25b872b 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/StatusButtonsPopup.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/itemviewholder/StatusButtonsPopup.kt @@ -92,20 +92,7 @@ internal class StatusButtonsPopup( buttonsForStatus.closeWindow = window val density = activity.density - fun dip(src: Float) = (src * density + 0.5f).toInt() - - val location = IntArray(2) - - listView.getLocationInWindow(location) - val listviewTop = location[1] - val clipTop = listviewTop + dip(8f) - val clipBottom = listviewTop + listView.height - dip(8f) - - anchor.getLocationInWindow(location) - val anchorLeft = location[0] - val anchorTop = location[1] - val anchorWidth = anchor.width - val anchorHeight = anchor.height + fun Int.dp() = (this * density + 0.5f).toInt() // popupの大きさ viewRoot.measure( @@ -115,6 +102,19 @@ internal class StatusButtonsPopup( val popupWidth = viewRoot.measuredWidth val popupHeight = viewRoot.measuredHeight + val location = IntArray(2) + + listView.getLocationInWindow(location) + val listviewTop = location[1] + val clipTop = listviewTop + 8.dp() + val clipBottom = listviewTop + listView.height - 8.dp() + + anchor.getLocationInWindow(location) + val anchorLeft = location[0] + val anchorTop = location[1] + val anchorWidth = anchor.width + val anchorHeight = anchor.height + // ポップアップウィンドウの左上(基準は親ウィンドウの左上) val popupX = anchorLeft + max(0, (anchorWidth - popupWidth) / 2) var popupY = anchorTop + anchorHeight / 2