-3
A
回答
1
創建一個自定義佈局是這樣的:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:padding="5dp">
<Switch
android:id="@+id/mySwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:text="Play with the Switch" />
<TextView
android:id="@+id/switchStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/mySwitch"
android:layout_marginTop="22dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
在你的活動,執行以下代碼:
public void showPopup(View v) {
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View popupView = layoutInflater.inflate(R.layout.popup_filter_layout, null);
popupWindow = new PopupWindow(
popupView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
//TODO do sth here on dismiss
}
});
popupWindow.showAsDropDown(v);
}
+0
謝謝你的迴應,我會先試一試 – Adzimzf
相關問題
- 1. 選項菜單佈局
- 2. Android菜單佈局首頁
- 3. 如何在佈局而不是菜單項中顯示ShareActionProvider?
- 4. 如何在查看佈局時自動在android中顯示菜單項(不單擊菜單按鈕)?
- 5. 如何在運行時在另一個佈局中插入佈局
- 6. 的Android沒有菜單項顯示在佈局
- 7. 的Android,在工具欄的佈局位置菜單項
- 8. 如何更改選項菜單項目佈局?
- 9. Bootstrap中的菜單佈局
- 10. 主菜單佈局
- 11. 插入佈局到另一個佈局使用其ID在android
- 12. Android從菜單佈局獲取屬性
- 13. Android飛出菜單佈局和樣式
- 14. 如何在系統菜單中插入新項目
- 15. 如何在Dreamweaver中創建自定義插入菜單項?
- 16. Android選項菜單 - 單行中的一個菜單項
- 17. Android - 添加自定義佈局彈出菜單項
- 18. Zend佈局 - 如何選擇一個菜單項?
- 19. Android菜單項分離器(不同行中的菜單項)
- 20. 如何在'發佈'版本上編譯某些Android菜單項
- 21. 如何使菜單項均勻分佈在菜單欄上
- 22. 如何在Android上進行此佈局?
- 23. 在菜單項中輸入?
- 24. 標籤佈局菜單在android中不工作
- 25. 定製joomla菜單佈局
- 26. Android的佈局,如何使兩個項目在一行
- 27. 如何在砌體佈局中使用下拉菜單?
- 28. 如何在框架佈局中滾動浮動操作菜單
- 29. 如何在佈局菜單中將鏈接標記爲「活動」?
- 30. 如何使用android中的選項卡進行佈局?
我建議你讀了Android佈局教程。 –
謝謝,你能給我一個具體的鏈接嗎? – Adzimzf
http://developer.android.com –