Пример #1
0
 public void centerPop(View view, Context context, Window mainWindow) {
   int[] wh = AppConfig.getInst().getDisplaySize(context);
   PopupWindow window = getWindow(view);
   if (window == null) {
     addPopup(view, mainWindow);
   } else {
     window.showAtLocation(mainWindow.getDecorView(), Gravity.CENTER, 0, 0);
   }
 }
Пример #2
0
 private GradientDrawable createGradientDrawable() {
   Context ctx = AppConfig.getInst().getContext();
   TypedArray typearray =
       ctx.obtainStyledAttributes(new int[] {R.attr.colorPrimary, R.attr.window_bg});
   int colorPrimary = typearray.getColor(0, Color.WHITE);
   int colorBack = typearray.getColor(1, Color.WHITE);
   typearray.recycle();
   int tenDP = DensityUtils.dip2px(ctx, 10);
   GradientDrawable gd =
       new GradientDrawable(
           GradientDrawable.Orientation.TOP_BOTTOM, new int[] {colorPrimary, colorBack});
   gd.setCornerRadii(new float[] {tenDP, tenDP, tenDP, tenDP, 0, 0, 0, 0});
   gd.setStroke(tenDP / 10, colorPrimary);
   gd.setGradientType(GradientDrawable.LINEAR_GRADIENT);
   gd.setGradientCenter(0.5f, 0.5f);
   gd.setShape(GradientDrawable.RECTANGLE);
   return gd;
 }