private void setupNavBarView(Context context, ViewGroup decorViewGroup) {
   mNavBarTintView = new View(context);
   LayoutParams params;
   if (mConfig.isNavigationAtBottom()) {
     params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getNavigationBarHeight());
     params.gravity = Gravity.BOTTOM;
   } else {
     params = new LayoutParams(mConfig.getNavigationBarWidth(), LayoutParams.MATCH_PARENT);
     params.gravity = Gravity.RIGHT;
   }
   mNavBarTintView.setLayoutParams(params);
   mNavBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
   mNavBarTintView.setVisibility(View.GONE);
   decorViewGroup.addView(mNavBarTintView);
 }
 protected static LayoutParams createSurfaceViewLayoutParams() {
   final LayoutParams layoutParams =
       new LayoutParams(
           android.view.ViewGroup.LayoutParams.FILL_PARENT,
           android.view.ViewGroup.LayoutParams.FILL_PARENT);
   layoutParams.gravity = Gravity.CENTER;
   return layoutParams;
 }
Beispiel #3
0
  private void initViews() {
    arrViews = new ArrayList<View>();
    baseView = new FrameLayout(context);
    mViewPager = new ViewPager(context);
    llDots = new LinearLayout(context);
    llDots.setOrientation(RadioGroup.HORIZONTAL);

    llDots.setGravity(Gravity.CENTER_HORIZONTAL);
    LinearLayout.LayoutParams paramsGroup =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, (int) (20 * fDensity));
    paramsGroup.gravity = Gravity.CENTER_HORIZONTAL;
    llDots.setLayoutParams(paramsGroup);
    if (resIds == null) return;
    for (int i = 0; i < resIds.length; i++) {
      ImageView iv = new ImageView(context);
      iv.setId(i);
      iv.setTag(i);
      iv.setOnClickListener(mClick);
      iv.setOnTouchListener(onTouch);
      iv.setBackgroundResource(resIds[i]);
      arrViews.add(iv);
      RelativeLayout rl = new RelativeLayout(context);
      android.widget.RelativeLayout.LayoutParams layoutParam =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
      layoutParam.addRule(RelativeLayout.CENTER_VERTICAL);
      ImageView dot = new ImageView(context);
      dot.setId(i);

      if (i == 0) {
        dot.setImageResource(dotResId1);
      } else {
        dot.setImageResource(dotResId2);
      }
      rl.addView(dot, layoutParam);
      rl.setPadding(0, 0, (int) (13 * fDensity), 0);
      llDots.addView(rl);
    }
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    baseView.addView(mViewPager, params);

    pageItemAdapter = new PageItemAdapter(arrViews);
    mViewPager.setAdapter(pageItemAdapter);
    mViewPager.setOnPageChangeListener(mPageChange);

    LayoutParams params2 =
        new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, (int) (20 * fDensity));
    params2.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    params2.bottomMargin = (int) (10 * fDensity);
    baseView.addView(llDots, params2);
    initPage();
    addContentView();
  }
 private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
   mStatusBarTintView = new View(context);
   LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
   params.gravity = Gravity.TOP;
   if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
     params.rightMargin = mConfig.getNavigationBarWidth();
   }
   mStatusBarTintView.setLayoutParams(params);
   mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
   mStatusBarTintView.setVisibility(View.GONE);
   decorViewGroup.addView(mStatusBarTintView);
 }
  @Override
  public LayoutParams createLayoutParams(final DisplayMetrics pDisplayMetrics) {
    final float realRatio = (float) pDisplayMetrics.widthPixels / pDisplayMetrics.heightPixels;

    final int width;
    final int height;
    if (realRatio < this.mRatio) {
      width = pDisplayMetrics.widthPixels;
      height = Math.round(width / this.mRatio);
    } else {
      height = pDisplayMetrics.heightPixels;
      width = Math.round(height * this.mRatio);
    }

    final LayoutParams layoutParams = new LayoutParams(width, height);

    layoutParams.gravity = Gravity.CENTER;
    return layoutParams;
  }
Beispiel #6
0
 /**
  * Button Constructor
  *
  * @param context : corresponding to the current context in the application
  * @param texte : text to display in the button
  * @param largeur : desired width for the button
  * @param hauteur : desired height for the button
  * @param margin : margin with the middle of the screen width (if negative on the left, on the
  *     right if positive)
  */
 public Bouton(Context context, String texte, int gravity, int largeur, int hauteur, int margin) {
   super(context);
   // Layout parameters definition for the button
   LayoutParams l =
       new FrameLayout.LayoutParams(
           ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   // text, width and height definition for the button
   this.setText(texte);
   this.setWidth(largeur);
   this.setHeight(hauteur);
   // button on the bottom of the screen
   l.gravity = gravity;
   // Definition of the margin as described in the parameters description
   if (margin >= 0) {
     l.leftMargin = margin;
   } else {
     l.leftMargin = -margin - largeur;
   }
   // Associate the layout parameters previously defined to the button
   this.setLayoutParams(l);
 }
  public static final void moveSpot(
      Context c,
      ImageView tv,
      GeoPoint p,
      float azimut,
      Location me,
      int screenWidth,
      float roll,
      int screenHeight,
      float pitch) {

    int angle = (int) (angleDirection(getSpotAngle(c, p, me), azimut));
    LayoutParams lp =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    int marginTop;

    if (pitch < screenHeight / 2) marginTop = (int) ((roll - 90) / 90 * screenHeight);
    else marginTop = -(int) ((roll - 90) / 90 * screenHeight);

    lp.setMargins(-angle * screenWidth / 90, marginTop, 0, 0);
    lp.gravity = Gravity.CENTER;
    tv.setLayoutParams(lp);
  }