在代码中创建布局的方法

第一种
imageView = new ImageView(this);
FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
decorView.addView(imageView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) imageView.getLayoutParams();
layoutParams.width = DubDisplay.dip2px(this, 38);
layoutParams.height = DubDisplay.dip2px(this, 38);
layoutParams.gravity = Gravity.BOTTOM | Gravity.END;
layoutParams.setMargins(0, 0, DubDisplay.dip2px(this, 20), DubDisplay.dip2px(this, 20));
imageView.setBackgroundResource(R.drawable.slipping_top);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
user_cash_listview.post(new Runnable() {
@Override
public void run() {
user_cash_listview.requestFocusFromTouch();
user_cash_listview.setSelection(0);
}
});
}
});

第二种
/*lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE// 设置为无焦点状态
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, // 没有边界
PixelFormat.TRANSLUCENT);// 半透明效果
lp.gravity = Gravity.BOTTOM;
lp.windowAnimations = R.style.bus_view;
windowManager.updateViewLayout(view, lp);*/
posted @ 2017-11-10 22:54  dub  阅读(178)  评论(0编辑  收藏  举报