我正在寻找使用 Android Jetpack compose 实现类似linkedIn 的弹出窗口。经过大量搜索后,我知道 Jetpack Compose 中有 Popup。最初我认为它在 Jetpack Compose 中会很直接,就像点击按钮以显示弹出窗口一样,如下面我们在 Android 旧方式中所做的那样。


Android 旧方式(没有 Jetpack Compose):
public static void onButtonShowPopupWindowClick(View view) {
// inflate the layout of the popup window
LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.popup_window, null);
// create the popup window
int width = LinearLayout.LayoutParams.WRAP_CONTENT;
int height = LinearLayout.LayoutParams.WRAP_CONTENT;
boolean focusable = true; // lets taps outside the popup