i 将电网格带入方言,但可以以任何方式改变其规模。 它总是在横向方向上填满屏幕。
protected Dialog getMoreMenuDialog(GridView gridView) {
Dialog d = new Dialog(AbstractActivity.this, R.style.menuDialog);
Window window = d.getWindow();
window.setGravity(Gravity.BOTTOM);
android.view.WindowManager.LayoutParams params = window.getAttributes();
params.y = findViewById(R.id.context_menu_ll).getHeight() + 3;
window.setAttributes(params);
d.setCancelable(true);
d.setCanceledOnTouchOutside(true);
int WRAP_CONTENT = LayoutParams.WRAP_CONTENT;
gridView.setLayoutParams(new LayoutParams(100, WRAP_CONTENT));
d.addContentView(gridView, new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
return d;
}
next is the place where calling this method
LayoutInflater factory = LayoutInflater.from(this);
final GridView gridView = (GridView) factory.inflate(R.layout.winner_moremenu, null);
mMoreMenuItemsGridView = gridView;
// gridView.setAdapter(new
// MenuAdapter(getApplicationContext(),getMoreMenuItems()));
OnItemClickListener il = getMenuGridOnItemClickListener();
if (il == null) {
il = mDefaultMoreMenuListener;
}
gridView.setOnItemClickListener(il);
return getMoreMenuDialog(gridView);
...... R.layout.winner_moremenu?next
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/menu_grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:numColumns="4"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
android:listSelector="@drawable/shap_context_menu_focus"
android:gravity="center"
/>