Android examples for User Interface:Layout
get Ad Layout
//package com.java2s; import android.graphics.PixelFormat; import android.view.Gravity; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; public class Main { public static WindowManager.LayoutParams getAdLayout(int location) { WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = WindowManager.LayoutParams.TYPE_PHONE; params.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.alpha = 1;//from w w w. j a v a2 s . c o m switch (location) { case 0://?? params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; break; case 1://?? params.gravity = Gravity.TOP | Gravity.LEFT; break; case 2://???? params.gravity = Gravity.TOP | Gravity.RIGHT; break; case 3://? params.gravity = Gravity.CENTER; break; case 4://?? params.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL; break; case 5://???? params.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; break; case 6://?? params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; break; case 7://?? params.gravity = Gravity.BOTTOM | Gravity.LEFT; break; case 8://???? params.gravity = Gravity.BOTTOM | Gravity.RIGHT; break; default: params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; break; } params.format = PixelFormat.RGBA_8888; return params; } }