android.widget.CompoundButton#getLayoutParams ( )源码实例Demo

下面列出了android.widget.CompoundButton#getLayoutParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Collection-Android   文件: FlexboxHelper.java
/**
 * Compound buttons (ex. {{@link android.widget.CheckBox}}, {@link android.widget.ToggleButton})
 * have a button drawable with minimum height and width specified for them.
 * To align the behavior with CSS Flexbox we want to respect these minimum measurement to avoid
 * these drawables from being cut off during calculation. When the compound button has a minimum
 * width or height already specified we will not make any change since we assume those were
 * voluntarily set by the user.
 *
 * @param compoundButton the compound button that need to be evaluated
 */
private void evaluateMinimumSizeForCompoundButton(CompoundButton compoundButton) {
    FlexItem flexItem = (FlexItem) compoundButton.getLayoutParams();
    int minWidth = flexItem.getMinWidth();
    int minHeight = flexItem.getMinHeight();

    Drawable drawable = CompoundButtonCompat.getButtonDrawable(compoundButton);
    int drawableMinWidth = drawable == null ? 0 : drawable.getMinimumWidth();
    int drawableMinHeight = drawable == null ? 0 : drawable.getMinimumHeight();
    flexItem.setMinWidth(minWidth == NOT_SET ? drawableMinWidth : minWidth);
    flexItem.setMinHeight(minHeight == NOT_SET ? drawableMinHeight : minHeight);
}
 
源代码2 项目: ToggleButtons   文件: ToggleGroup.java
void drawDividersVertical(Canvas canvas) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final CompoundButton child = (CompoundButton) getChildAt(i);
        if (hasDividerBeforeChildAt(i)) {
            final LinearLayoutCompat.LayoutParams lp = (LinearLayoutCompat.LayoutParams) child.getLayoutParams();
            final int top = child.getTop() - lp.topMargin - mDividerHeight;
            drawHorizontalDivider(canvas, top);
        }
    }
}
 
源代码3 项目: ToggleButtons   文件: ToggleGroup.java
void drawDividersHorizontal(Canvas canvas) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final CompoundButton child = (CompoundButton) getChildAt(i);
        if (hasDividerBeforeChildAt(i)) {
            final LinearLayoutCompat.LayoutParams lp = (LinearLayoutCompat.LayoutParams) child.getLayoutParams();
            final int left = child.getLeft() - lp.leftMargin - mDividerWidth;
            drawVerticalDivider(canvas, left);
        }
    }
}
 
源代码4 项目: ToggleButtons   文件: ToggleGroup.java
void drawDividersVertical(Canvas canvas) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final CompoundButton child = (CompoundButton) getChildAt(i);
        if (hasDividerBeforeChildAt(i)) {
            final LinearLayoutCompat.LayoutParams lp = (LinearLayoutCompat.LayoutParams) child.getLayoutParams();
            final int top = child.getTop() - lp.topMargin - mDividerHeight;
            drawHorizontalDivider(canvas, top);
        }
    }
}
 
源代码5 项目: ToggleButtons   文件: ToggleGroup.java
void drawDividersHorizontal(Canvas canvas) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final CompoundButton child = (CompoundButton) getChildAt(i);
        if (hasDividerBeforeChildAt(i)) {
            final LinearLayoutCompat.LayoutParams lp = (LinearLayoutCompat.LayoutParams) child.getLayoutParams();
            final int left = child.getLeft() - lp.leftMargin - mDividerWidth;
            drawVerticalDivider(canvas, left);
        }
    }
}