我試圖顯示一個ListPopupWindow單擊列表視圖項目。 ListPopupWindow中的項目是可滾動的。但我無法給底部邊緣,它觸及屏幕底部。ListPopupWindow marign底部不工作
private ListPopupWindow getListMenu(Context context, View anchor, String[] options) {
Context wrapper = new ContextThemeWrapper(context, R.style.ProfilePicPopUp);
ListPopupWindow popupWindow = new ListPopupWindow(wrapper);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
R.layout.listpopup_item, options);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
popupWindow.setAdapter(adapter);
popupWindow.setAnchorView(anchor);
popupWindow.getAnimationStyle();
popupWindow.setModal(true);
popupWindow.setHorizontalOffset((anchor.getWidth()*3)/4);
popupWindow.setVerticalOffset(-anchor.getHeight()/4);
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
int width = metrics.widthPixels;
popupWindow.setWidth((width * 3)/4); // note: don't use pixels, use a dimen resource
return popupWindow;
}
listpopup_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
fontPath="Lato-Bold.ttf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/profilepic_option_click_selector"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:paddingBottom="7dp"
android:paddingEnd="15dip"
android:paddingStart="14dip"
android:paddingTop="7dp"
android:text="sample"
android:textColor="@color/white" />
你可以發佈你的'xml'佈局的自定義視圖? –