交互设计 Day02

PopupWindow弹出窗体可以在任意位置弹出窗体,而对话框只能出现屏幕最中间
showAsDropDown(View anchor, int xoff, int yoff) 可以设置显示的位置 相对于兄弟控件
showAtLocation(View parent, int gravity, int x, int y) 相对于父控件
public PopupWindow (Context context):context上下文对象
setContentView():设置自定义布局
setWidth():设置宽度
setHeight():设置高度
必须要设置的3个属性

可以勇敢布局填充其来显示其他的页面布局 调用其它布局的方法
opupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(false);
设置按钮的焦点

WindowManager.LayoutParams attributes = getWindow().getAttributes();
attributes.alpha=0.3f;
getWindow().setAttributes(attributes);
窗体的管理

popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
WindowManager.LayoutParams attributes = getWindow().getAttributes();
attributes.alpha=1.0f;
getWindow().setAttributes(attributes);
}
});

当PopopWindow关闭时的方法

菜单

public boolean onCreateOptionsMenu(Menu menu) {
menu.add(1,Red,4,“红色”).setIcon(R.mipmap.ic_launcher);
menu.add(1,Yellow,2,“黄色”).setIcon(R.mipmap.ic_launcher);
menu.add(1,Green,1,“绿色”).setIcon(R.mipmap.ic_launcher);
menu.add(1,White,3,“白色”).setIcon(R.mipmap.ic_launcher);
menu.add(1,Pouple,5,“蓝色”).setIcon(R.mipmap.ic_launcher);
Log.i(“MenuActivity”,“FAFSA”);
// SubMenu subMenu=menu.addSubMenu(“jh”);
// subMenu.add(2,)
return true;

}
重写方法 onCreateOptionsMenu
参数依次为 组号  id 顺序 文本 也可以设置图片 低版本不会显示
retrun  turn 才会显示

重写方法onOptionsItemSelected  做条目的监听事件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值