private void addDivider(boolean iOSStylable) {
    ImageView divider = new ImageView(mContext);
    divider.setScaleType(ScaleType.FIT_XY);
    divider.setBackgroundColor(getResources().getColor(R.color.setting_view_item_bg_normal));
    divider.setImageResource(R.drawable.divider);

    LayoutParams lps = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lps.gravity = Gravity.RIGHT;

    if (iOSStyleable) {
      int paddingLeft =
          (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_PX,
                      getResources().getDimensionPixelSize(R.dimen.setting_view_min_height),
                      getResources().getDisplayMetrics())
              + (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_PX,
                      getResources().getDimensionPixelSize(R.dimen.setting_view_lr_padding),
                      getResources().getDisplayMetrics());
      divider.setPadding(paddingLeft, 0, 0, 0);
    }

    addView(divider, lps);
  }
 private void setCallLockerVisibility(int visibility) {
   controlMode = visibility == View.VISIBLE ? MODE_LOCKER : MODE_NO_ACTION;
   setVisibility(visibility);
   if (visibility == View.VISIBLE) {
     // Inflate sub views only if display is requested
     if (lockerWidget == null) {
       switch (lockerWidgetType) {
         case LOCKER_SLIDINGTAB:
           lockerWidget = new SlidingTab(getContext());
           break;
         case LOCKER_BUTTON:
           lockerWidget = new AlternateUnlocker(getContext());
           break;
         case LOCKER_GLOWPAD:
           lockerWidget = new GlowPadView(getContext());
           break;
         default:
           break;
       }
       lockerWidget.setOnLeftRightListener(this);
       lockerWidget.setTypeOfLock(TypeOfLock.CALL);
       LayoutParams lp =
           new LayoutParams(lockerWidget.getLayoutingWidth(), lockerWidget.getLayoutingHeight());
       if (lockerWidget.getLayoutingHeight() == LayoutParams.WRAP_CONTENT
           || lockerWidget.getLayoutingWidth() == LayoutParams.WRAP_CONTENT) {
         lp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
       }
       this.addView((View) lockerWidget, lp);
     }
   }
   if (lockerWidget != null) {
     lockerWidget.setVisibility(visibility);
     lockerWidget.resetView();
   }
 }
  private void init() {
    setOrientation(LinearLayout.VERTICAL);

    textView = new TextView(getContext());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
    textView.setTextColor(0xff3b84c0);
    addView(textView);
    LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
    layoutParams.width = LayoutParams.WRAP_CONTENT;
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    layoutParams.leftMargin = AndroidUtilities.dp(8);
    layoutParams.rightMargin = AndroidUtilities.dp(8);
    layoutParams.topMargin = AndroidUtilities.dp(6);
    layoutParams.bottomMargin = AndroidUtilities.dp(4);
    if (LocaleController.isRTL) {
      textView.setGravity(Gravity.RIGHT);
      layoutParams.gravity = Gravity.RIGHT;
    }
    textView.setLayoutParams(layoutParams);

    View view = new View(getContext());
    view.setBackgroundColor(0xff6caae4);
    addView(view);
    layoutParams = (LayoutParams) view.getLayoutParams();
    layoutParams.weight = LayoutParams.MATCH_PARENT;
    layoutParams.height = AndroidUtilities.dp(1);
    view.setLayoutParams(layoutParams);
  }
  public void showNumberLayout(List<ShowInfoBean> list) {
    LogUtil.e(getClass(), "showNumberLayout list size==>" + list.size());
    showNumberLayout.removeAllViews();
    LayoutParams layoutParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    LinearLayout itemLayout = null;
    for (int i = 0; i < list.size(); i++) {
      LogUtil.e(getClass(), "showNumberLayout i==>" + i);
      if (i % 3 == 0) {
        itemLayout =
            (LinearLayout)
                LayoutInflater.from(showNumberLayout.getContext()).inflate(R.layout.show, null);
        itemLayout.setLayoutParams(layoutParams);
        showNumberLayout.addView(itemLayout);
      }
      RelativeLayout itemView =
          (RelativeLayout)
              LayoutInflater.from(showNumberLayout.getContext()).inflate(R.layout.show_item, null);
      initItem(itemView, list.get(i), i);
      LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      params.setMargins(20, 20, 0, 0);
      params.weight = 1;
      itemView.setLayoutParams(params);
      itemLayout.addView(itemView);
    }
  }
  private void onPanelDragged(int newTop) {
    mLastNotDraggingSlideState = mSlideState;
    mSlideState = PanelState.DRAGGING;
    // Recompute the slide offset based on the new top position
    mSlideOffset = computeSlideOffset(newTop);
    applyParallaxForCurrentSlideOffset();
    // Dispatch the slide event
    dispatchOnPanelSlide(mSlideableView);
    // If the slide offset is negative, and overlay is not on, we need to
    // increase the
    // height of the main content
    LayoutParams lp = (LayoutParams) mMainView.getLayoutParams();
    int defaultHeight = getHeight() - getPaddingBottom() - getPaddingTop() - mPanelHeight;

    if (mSlideOffset <= 0 && !mOverlayContent) {
      // expand the main view
      lp.height =
          mIsSlidingUp
              ? (newTop - getPaddingBottom())
              : (getHeight() - getPaddingBottom() - mSlideableView.getMeasuredHeight() - newTop);
      mMainView.requestLayout();
    } else if (lp.height != defaultHeight && !mOverlayContent) {
      lp.height = defaultHeight;
      mMainView.requestLayout();
    }
  }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    this.innerView.measure(widthMeasureSpec, heightMeasureSpec);
    ImageView iv1 = (ImageView) this.innerView.findViewById(R.id.top_item_1);
    LayoutParams lp = iv1.getLayoutParams();
    lp.height = iv1.getMeasuredWidth();
    iv1.setLayoutParams(lp);

    ImageView iv2 = (ImageView) this.innerView.findViewById(R.id.top_item_2);
    lp = iv2.getLayoutParams();
    lp.height = iv2.getMeasuredWidth();
    iv2.setLayoutParams(lp);

    ImageView iv3 = (ImageView) this.innerView.findViewById(R.id.top_item_3);
    lp = iv3.getLayoutParams();
    lp.height = iv3.getMeasuredWidth();
    iv3.setLayoutParams(lp);

    TextView tv = (TextView) this.innerView.findViewById(R.id.top_item_others);
    lp = tv.getLayoutParams();
    lp.height = iv3.getMeasuredWidth();
    tv.setLayoutParams(lp);

    this.innerView.measure(widthMeasureSpec, heightMeasureSpec);

    this.setMeasuredDimension(
        this.innerView.getMeasuredWidth(), this.innerView.getMeasuredHeight());
  }
  public HierarchyElementView(Context context, HierarchyElement it) {
    super(context);

    setColor(it.getColor());

    mIcon = new ImageView(context);
    mIcon.setImageDrawable(it.getIcon());
    mIcon.setId(1);
    mIcon.setPadding(0, 15, 5, 0);
    addView(
        mIcon,
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    mPrimaryTextView = new TextView(context);
    mPrimaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Large);
    mPrimaryTextView.setText(it.getPrimaryText());
    mPrimaryTextView.setPadding(0, 7, 0, 0);
    mPrimaryTextView.setId(2);
    LayoutParams l =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    l.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mPrimaryTextView, l);

    mSecondaryTextView = new TextView(context);
    mSecondaryTextView.setText(it.getSecondaryText());
    mSecondaryTextView.setPadding(0, 0, 0, 7);
    mSecondaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Small);
    LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.BELOW, mPrimaryTextView.getId());
    lp.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mSecondaryTextView, lp);
  }
Exemplo n.º 8
0
  @Override
  public void onLayout(float l, float t, float r, float b) {

    LayoutParams childLayoutParams = child.getLayoutParams();
    childLayoutParams.computeFrame(layoutParams);
    child.layout(
        childLayoutParams.mComputedLeft
            + layoutParams.computeMesure(childLayoutParams.getLayoutMarginLeft())
            + layoutParams.computeMesure(childLayoutParams.getLayoutPaddingLeft()),
        childLayoutParams.mComputedTop
            + layoutParams.computeMesure(childLayoutParams.getLayoutMarginTop())
            + layoutParams.computeMesure(childLayoutParams.getLayoutPaddingTop()),
        childLayoutParams.mComputedRight
            - layoutParams.computeMesure(childLayoutParams.getLayoutMarginRight())
            - layoutParams.computeMesure(childLayoutParams.getLayoutPaddingRight()),
        childLayoutParams.mComputedBottom
            - layoutParams.computeMesure(childLayoutParams.getLayoutMarginBottom())
            - layoutParams.computeMesure(childLayoutParams.getLayoutPaddingBottom()));

    float oldCenterX = oldWidth / 2 - scrollOffsetX;
    float oldCenterY = oldHeight / 2 - scrollOffsetY;

    setScrollCenter(new Point(oldCenterX, oldCenterY));

    oldWidth = layoutParams.getWidth();
    oldHeight = layoutParams.getHeight();
  }
Exemplo n.º 9
0
  /**
   * Measure a child view to fit within cell-based formatting. The child's width will be measured to
   * a whole multiple of cellSize.
   *
   * <p>
   *
   * <p>Sets the expandable and cellsUsed fields of LayoutParams.
   *
   * @param child Child to measure
   * @param cellSize Size of one cell
   * @param cellsRemaining Number of cells remaining that this view can expand to fill
   * @param parentHeightMeasureSpec MeasureSpec used by the parent view
   * @param parentHeightPadding Padding present in the parent view
   * @return Number of cells this child was measured to occupy
   */
  static int measureChildForCells(
      View child,
      int cellSize,
      int cellsRemaining,
      int parentHeightMeasureSpec,
      int parentHeightPadding) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();

    final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) - parentHeightPadding;
    final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec);
    final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode);

    int cellsUsed = 0;
    if (cellsRemaining > 0) {
      final int childWidthSpec =
          MeasureSpec.makeMeasureSpec(cellSize * cellsRemaining, MeasureSpec.AT_MOST);
      child.measure(childWidthSpec, childHeightSpec);

      final int measuredWidth = child.getMeasuredWidth();
      cellsUsed = measuredWidth / cellSize;
      if (measuredWidth % cellSize != 0) cellsUsed++;
    }

    final ActionMenuItemView itemView =
        child instanceof ActionMenuItemView ? (ActionMenuItemView) child : null;
    final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText();
    lp.expandable = expandable;

    lp.cellsUsed = cellsUsed;
    final int targetWidth = cellsUsed * cellSize;
    child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), childHeightSpec);
    return cellsUsed;
  }
Exemplo n.º 10
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();

    View view = LayoutInflater.from(getContext()).inflate(R.layout.load_view, null);

    mDistance = dip2px(54f);

    LayoutParams layoutParams =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    layoutParams.gravity = Gravity.CENTER;

    shapeLoadingView = (ShapeLoadingView) view.findViewById(R.id.shapeLoadingView);

    indicationIm = (ImageView) view.findViewById(R.id.indication);
    loadTextView = (TextView) view.findViewById(R.id.promptTV);

    setLoadingText(loadText);

    addView(view, layoutParams);

    this.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            freeFall();
          }
        },
        900);
  }
Exemplo n.º 11
0
  @Override
  protected void measureChildWithMargins(
      View child,
      int parentWidthMeasureSpec,
      int widthUsed,
      int parentHeightMeasureSpec,
      int heightUsed) {
    final int index = indexOfChild(child);
    final int orientation = getOrientation();
    final LayoutParams params = (LayoutParams) child.getLayoutParams();
    if (hasDividerBeforeChildAt(index)) {
      if (orientation == VERTICAL) {
        // Account for the divider by pushing everything up
        params.topMargin = mDividerHeight;
      } else {
        // Account for the divider by pushing everything left
        params.leftMargin = mDividerWidth;
      }
    }

    final int count = getChildCount();
    if (index == count - 1) {
      if (hasDividerBeforeChildAt(count)) {
        if (orientation == VERTICAL) {
          params.bottomMargin = mDividerHeight;
        } else {
          params.rightMargin = mDividerWidth;
        }
      }
    }
    super.measureChildWithMargins(
        child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
  }
Exemplo n.º 12
0
  public void parse(TimeLineModel data) {
    this.mData = data;
    if (data.hasPics || data.hasRepostPics) {
      mPic.setVisibility(GONE);
      mGridView.setVisibility(VISIBLE);
      mGridView.setAdapter(new GridPicsAdapter(getContext(), data.pics));
      LayoutParams lp = (LayoutParams) mCommentCount.getLayoutParams();
      lp.addRule(BELOW, R.id.timeline_listitem_picgrid);
      mCommentCount.setLayoutParams(lp);
    } else {
      mGridView.setVisibility(GONE);
      LayoutParams lp = (LayoutParams) mCommentCount.getLayoutParams();
      lp.addRule(BELOW, R.id.timeline_listitem_pic);
      mCommentCount.setLayoutParams(lp);
      if (data.hasPic || data.hasRepostPic) {
        mPic.setVisibility(VISIBLE);
        mPic.setGif(TextUtils.isGifLink(data.pics.get(0)));
        if (NetworkUtils.isWifi(getContext())) {
          ImageLoader.getInstance()
              .displayImage(data.pics.get(0).replace("thumbnail", "bmiddle"), mPic);
        } else {
          ImageLoader.getInstance().displayImage(data.pics.get(0), mPic);
        }
      } else {
        mPic.setVisibility(GONE);
      }
    }
    if (data.topics.size() == 0) {
      mTopic.setVisibility(INVISIBLE);
    } else {
      mTopic.setVisibility(VISIBLE);
      mTopic.setText(data.topics.get(0));
    }
    if (data.hasRepost) {
      mLine.setVisibility(VISIBLE);
      mRepostName.setVisibility(VISIBLE);
      mRepostText.setVisibility(VISIBLE);
      mRepostName.setText(data.repostName);
      mRepostText.setText(data.repostText);
    } else {
      mLine.setVisibility(GONE);
      mRepostName.setVisibility(GONE);
      mRepostText.setVisibility(GONE);
    }
    if (data.commentCount != 0) {
      mCommentCount.setText(data.commentCount + "");
    } else {
      mCommentCount.setText("评论");
    }
    if (data.repostCount != 0) {
      mRepostCount.setText(data.repostCount + "");
    } else {
      mRepostCount.setText("转发");
    }

    mText.setText(data.text);
    mName.setText(data.name);
    mTime.setText(data.time);
    ImageLoader.getInstance().displayImage(data.headUrl, mHead, mOptions);
  }
  private void addIconTabBådeTekstOgBillede(
      final int position, int resId, Bitmap res, String title) {
    FrameLayout tabfl = new FrameLayout(getContext());
    if (Build.VERSION.SDK_INT > 11) tabfl.setLayoutTransition(new LayoutTransition());
    ImageView tabi = new ImageView(getContext());
    tabi.setContentDescription(title);
    if (res != null) {
      tabi.setImageBitmap(res);
      tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
      tabi.setAdjustViewBounds(true);
    } else {
      tabi.setImageResource(resId);
    }
    tabi.setVisibility(View.GONE);
    TextView tabt = new TextView(getContext());
    tabt.setText(title);
    tabt.setTypeface(App.skrift_gibson);
    tabt.setGravity(Gravity.CENTER);
    tabt.setSingleLine();

    tabfl.addView(tabi);
    tabfl.addView(tabt);

    LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
    lp.gravity = Gravity.CENTER;
    lp = (LayoutParams) tabt.getLayoutParams();
    lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.gravity = Gravity.CENTER;

    addTab(position, tabfl);
  }
  public void initView(Context context) {
    mContext = context;
    setGravity(Gravity.CENTER);
    setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    progressCon = new SimpleViewSwithcer(context);
    progressCon.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    AVLoadingIndicatorView progressView = new AVLoadingIndicatorView(this.getContext());
    progressView.setIndicatorColor(0xffB5B5B5);
    progressView.setIndicatorId(ProgressStyle.BallSpinFadeLoader);
    progressCon.setView(progressView);

    addView(progressCon);
    mText = new TextView(context);
    mText.setText("正在加载...");

    LayoutParams layoutParams =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins((int) getResources().getDimension(R.dimen.textandiconmargin), 0, 0, 0);

    mText.setLayoutParams(layoutParams);
    addView(mText);
  }
Exemplo n.º 15
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    menu = findViewById(menuId);
    if (menu == null) {
      throw new RuntimeException();
    }
    rightLayout = findViewById(rightLayoutId);
    if (rightLayout == null) {
      throw new RuntimeException();
    }

    removeView(menu);
    removeView(rightLayout);

    addView(menu);
    addView(rightLayout);

    touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

    // 动态设置左边menu的右边边框距离
    final float scale = myContext.getResources().getDisplayMetrics().density;
    LayoutParams params = (LayoutParams) menu.getLayoutParams();
    params.rightMargin = (int) (FINAL_DP * scale + 0.5f);
    MyLog.e(TAG, "params.rightMargin=" + params.rightMargin);
    menu.setLayoutParams(params);

    initView();
  }
Exemplo n.º 16
0
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   boolean z;
   boolean wasFormatted = this.mFormatItems;
   if (MeasureSpec.getMode(widthMeasureSpec) == 1073741824) {
     z = true;
   } else {
     z = false;
   }
   this.mFormatItems = z;
   if (wasFormatted != this.mFormatItems) {
     this.mFormatItemsWidth = 0;
   }
   int widthSize = MeasureSpec.getSize(widthMeasureSpec);
   if (!(!this.mFormatItems || this.mMenu == null || widthSize == this.mFormatItemsWidth)) {
     this.mFormatItemsWidth = widthSize;
     this.mMenu.onItemsChanged(true);
   }
   int childCount = getChildCount();
   if (!this.mFormatItems || childCount <= 0) {
     for (int i = 0; i < childCount; i++) {
       LayoutParams lp = (LayoutParams) getChildAt(i).getLayoutParams();
       lp.rightMargin = 0;
       lp.leftMargin = 0;
     }
     super.onMeasure(widthMeasureSpec, heightMeasureSpec);
     return;
   }
   onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec);
 }
Exemplo n.º 17
0
 static int measureChildForCells(
     View child,
     int cellSize,
     int cellsRemaining,
     int parentHeightMeasureSpec,
     int parentHeightPadding) {
   LayoutParams lp = (LayoutParams) child.getLayoutParams();
   int childHeightSpec =
       MeasureSpec.makeMeasureSpec(
           MeasureSpec.getSize(parentHeightMeasureSpec) - parentHeightPadding,
           MeasureSpec.getMode(parentHeightMeasureSpec));
   ActionMenuItemView itemView =
       child instanceof ActionMenuItemView ? (ActionMenuItemView) child : null;
   boolean hasText = itemView != null && itemView.hasText();
   int cellsUsed = 0;
   if (cellsRemaining > 0 && (!hasText || cellsRemaining >= 2)) {
     child.measure(
         MeasureSpec.makeMeasureSpec(cellSize * cellsRemaining, ExploreByTouchHelper.INVALID_ID),
         childHeightSpec);
     int measuredWidth = child.getMeasuredWidth();
     cellsUsed = measuredWidth / cellSize;
     if (measuredWidth % cellSize != 0) {
       cellsUsed++;
     }
     if (hasText && cellsUsed < 2) {
       cellsUsed = 2;
     }
   }
   boolean expandable = !lp.isOverflowButton && hasText;
   lp.expandable = expandable;
   lp.cellsUsed = cellsUsed;
   child.measure(MeasureSpec.makeMeasureSpec(cellsUsed * cellSize, 1073741824), childHeightSpec);
   return cellsUsed;
 }
Exemplo n.º 18
0
 public void setAngle(int angle) {
   View view = getView();
   LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
   layoutParams.angle = angle;
   this.angle = angle;
   this.angleChanged = true;
 }
Exemplo n.º 19
0
  private void init(Context context) {
    mContext = context;
    loadDefaults();
    initGraphicTools();
    setWillNotDraw(false);

    setFocusable(false);
    setClickable(false);

    mTimerView = new TextView(mContext);
    mTimerView.setId(ViewHelper.generateViewId());
    mTimerView.setTextColor(
        mContext.getResources().getColor(R.color.camera_overlay_timerTextColor));
    mTimerView.setTextSize(
        mContext.getResources().getDimension(R.dimen.camera_overlay_timerTextSize));

    float shadowRadius = mContext.getResources().getDimension(R.dimen.camera_overlay_shadowRadius);
    mTimerView.setShadowLayer(shadowRadius, 0, 0, Color.BLACK);
    LayoutParams timerLParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    timerLParams.addRule(CENTER_IN_PARENT, mTimerView.getId());
    addView(mTimerView, timerLParams);

    mCountdownAnimation = AnimationUtils.loadAnimation(mContext, R.anim.shot_countdown_scale_up);
  }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // If we've been given an exact size to match, apply special formatting during layout.
    final boolean wasFormatted = mFormatItems;
    mFormatItems = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;

    if (wasFormatted != mFormatItems) {
      mFormatItemsWidth = 0; // Reset this when switching modes
    }

    // Special formatting can change whether items can fit as action buttons.
    // Kick the menu and update presenters when this changes.
    final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) {
      mFormatItemsWidth = widthSize;
      mMenu.onItemsChanged(true);
    }

    final int childCount = getChildCount();
    if (mFormatItems && childCount > 0) {
      onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec);
    } else {
      // Previous measurement at exact format may have set margins - reset them.
      for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        lp.leftMargin = lp.rightMargin = 0;
      }
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
  }
Exemplo n.º 21
0
 @Override
 protected void onLayout(boolean changed, int l, int t, int r, int b) {
   // TODO Auto-generated method stub
   if (changed) {
     int left = padNumber * itemWidth;
     int top = 0;
     int right = left + itemWidth;
     int bottom = height;
     for (int i = 0; i < getChildCount(); i++) {
       ImageView imageView = (ImageView) getChildAt(i);
       LayoutParams imageViewLayoutParams = imageView.getLayoutParams();
       imageViewLayoutParams.width = itemWidth;
       imageViewLayoutParams.height = height;
       //				Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
       Bitmap bitmap = bitmapList.get(i);
       if (bitmap != null) {
         Bitmap reflectedBitmap = getReflectedBitmap(bitmap);
         imageView.setImageBitmap(reflectedBitmap);
       }
       imageView.setLayoutParams(imageViewLayoutParams);
       left = itemWidth * (i + padNumber);
       right = left + itemWidth;
       imageView.layout(left, top, right, bottom);
       if (i < middleIndex) {
         imageView.setRotationY(ROTATE_DEGREE);
       } else if (i == middleIndex) {
         imageView.setRotationY(0);
       } else {
         imageView.setRotationY(-ROTATE_DEGREE);
       }
     }
   }
 }
Exemplo n.º 22
0
 @Override
 protected void onScrollChanged(int l, int t, int oldl, int oldt) {
   LayoutParams lp = (LayoutParams) progressbar.getLayoutParams();
   lp.x = l;
   lp.y = t;
   progressbar.setLayoutParams(lp);
   super.onScrollChanged(l, t, oldl, oldt);
 }
Exemplo n.º 23
0
 private void createPager(final Context context) {
   mCalendarPager = new CalendarPagerView(context);
   mCalendarPager.setCalendarView(this);
   mCalendarPager.setCalendarListener(mCalendarListener);
   LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
   params.addRule(BELOW, mDayOfWeekGrid.getId());
   addView(mCalendarPager, params);
 }
Exemplo n.º 24
0
 public void setMenuHeight(int measuredHeight) {
   Log.i("byz", "pos = " + position + ", height = " + measuredHeight);
   LayoutParams params = (LayoutParams) mMenuView.getLayoutParams();
   if (params.height != measuredHeight) {
     params.height = measuredHeight;
     mMenuView.setLayoutParams(mMenuView.getLayoutParams());
   }
 }
Exemplo n.º 25
0
  private void createDayOfWeekView(final Context context) {
    mDayOfWeekGrid = new DayOfWeekGridView(context);
    mDayOfWeekGrid.setId(2);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.addRule(BELOW, mTitle.getId());
    addView(mDayOfWeekGrid, params);
  }
 public void updateResources() {
   if (mContentHolder != null) {
     final LayoutParams lp = (LayoutParams) mContentHolder.getLayoutParams();
     lp.width = getResources().getDimensionPixelSize(R.dimen.notification_panel_width);
     lp.gravity = getResources().getInteger(R.integer.notification_panel_layout_gravity);
     mContentHolder.setLayoutParams(lp);
   }
 }
Exemplo n.º 27
0
  public void show() {
    mArrow.clearAnimation();
    mArrow.setVisibility(View.GONE);
    mLoaderTips.setText(R.string.g_pull_up_for_more);

    LayoutParams lp = (LayoutParams) mFooter.getLayoutParams();
    lp.height = LayoutParams.WRAP_CONTENT;
    mFooter.setLayoutParams(lp);
  }
Exemplo n.º 28
0
  @Override
  public void addView(View child, int index, ViewGroup.LayoutParams params) {
    // Generate an id for each view, this assumes we have at most 256x256 cells
    // per workspace screen
    final LayoutParams cellParams = (LayoutParams) params;
    cellParams.regenerateId = true;

    super.addView(child, index, params);
  }
Exemplo n.º 29
0
  private void setUpCardView() {
    LayoutParams params = new LayoutParams(mCardView.getLayoutParams());
    params.topMargin = mMarginTop;
    params.bottomMargin = mMarginBottom;
    params.leftMargin = mMarginLeft;
    params.rightMargin = mMarginRight;

    mCardView.setLayoutParams(params);
  }
  protected TextView buttonClear(View topView) {
    TextView v = getNumberButton(R.string.other_calculater_button_clear, -1);
    LayoutParams params = (LayoutParams) v.getLayoutParams();
    params.addRule(BELOW, topView.getId());
    params.addRule(ALIGN_PARENT_RIGHT);
    v.setLayoutParams(params);

    return v;
  }