当前位置: 首页>>代码示例>>Java>>正文


Java View.setPadding方法代码示例

本文整理汇总了Java中android.view.View.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java View.setPadding方法的具体用法?Java View.setPadding怎么用?Java View.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateTabStyles

import android.view.View; //导入方法依赖的package包/类
private void updateTabStyles() {
        for (int i = 0; i < mTabCount; i++) {
            View tabView = mTabsContainer.getChildAt(i);
            tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
            tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
            tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            if (mTextAllCaps) {
                tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
            }

            if (mTextBold == TEXT_BOLD_BOTH) {
                tv_tab_title.getPaint().setFakeBoldText(true);
            } else if (mTextBold == TEXT_BOLD_NONE) {
                tv_tab_title.getPaint().setFakeBoldText(false);
            }
        }
    }
 
开发者ID:767954322,项目名称:FlycoTabLayout,代码行数:20,代码来源:SegmentTabLayout.java

示例2: inflateAction

import android.view.View; //导入方法依赖的package包/类
/**
 * Inflates a {@link View} with the given {@link Action}.
 *
 * @param action the action to inflate
 * @return a view
 */
private View inflateAction(Action action) {
    View view;
    if (TextUtils.isEmpty(action.getText())) {
        ImageView img = new ImageView(getContext());
        img.setImageResource(action.getDrawable());
        view = img;
    } else {
        TextView text = new TextView(getContext());
        text.setGravity(Gravity.CENTER);
        text.setText(action.getText());
        text.setTextSize(DEFAULT_ACTION_TEXT_SIZE);
        if (mActionTextColor != 0) {
            text.setTextColor(mActionTextColor);
        }
        view = text;
    }

    view.setPadding(mActionPadding, 0, mActionPadding, 0);
    view.setTag(action);
    view.setOnClickListener(this);
    return view;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:29,代码来源:TitleBar.java

示例3: setPadding

import android.view.View; //导入方法依赖的package包/类
public static void setPadding(View view, int left, int top, int right, int bottom) {
    int scaledLeft = scaleValue(view.getContext(), left);
    int scaledTop = scaleValue(view.getContext(), top);
    int scaledRight = scaleValue(view.getContext(), right);
    int scaledBottom = scaleValue(view.getContext(), bottom);
    view.setPadding(scaledLeft, scaledTop, scaledRight, scaledBottom);
}
 
开发者ID:yangchong211,项目名称:YCWeather,代码行数:8,代码来源:ViewUtil.java

示例4: setInsets

import android.view.View; //导入方法依赖的package包/类
public static void setInsets(Activity context, View view) {
    if (Utils.hasKitKat()) {
        SystemBarTintManager tintManager = new SystemBarTintManager(context);
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        view.setPadding(0, config.getPixelInsetTop(true), config.getPixelInsetRight(), 2*config.getPixelInsetBottom());
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:8,代码来源:SystemBarTintManager.java

示例5: setHeightAndPadding

import android.view.View; //导入方法依赖的package包/类
/** 增加View的高度以及paddingTop,增加的值为状态栏高度.一般是在沉浸式全屏给ToolBar用的 */
public static void setHeightAndPadding(Context context, View view) {
    if (Build.VERSION.SDK_INT >= MIN_API) {
        ViewGroup.LayoutParams lp = view.getLayoutParams();
        lp.height += getStatusBarHeight(context);//增高
        view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context),
                view.getPaddingRight(), view.getPaddingBottom());
    }
}
 
开发者ID:scwang90,项目名称:SmartRefreshLayout,代码行数:10,代码来源:StatusBarUtil.java

示例6: setTranslucentStatus

import android.view.View; //导入方法依赖的package包/类
/**
 * 设置透明状态栏并对某个view 拉伸,达到沉浸式状态栏的效果。仅支持19(含)~21(不含),
 * 5.0及以上版本建议使用 {@link #setStatusBarColor(Activity, int)}
 *
 * @param view
 */
public static void setTranslucentStatus(Activity activity, View view) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        view.setPadding(view.getPaddingLeft(),
                DeviceInfo.getStatusHeight(activity)+view.getPaddingTop(),
                view.getPaddingRight(),
                view.getPaddingBottom());
    }
}
 
开发者ID:sundevin,项目名称:utilsLibrary,代码行数:20,代码来源:ActivityUtils.java

示例7: setPadding

import android.view.View; //导入方法依赖的package包/类
protected void setPadding(View v, int depth, int indent) {
  if (v == null || depth < 0) {
    throw new IllegalArgumentException("illegal params");
  }
  if (indent < 0) {
    indent = baseIndent;
  }
  v.setPadding(indent * (depth + 1),
          v.getPaddingTop(),
          v.getPaddingRight(),
          v.getPaddingBottom());
}
 
开发者ID:LeeReindeer,项目名称:Tree2View,代码行数:13,代码来源:TreeAdapter.java

示例8: updateTextSize

import android.view.View; //导入方法依赖的package包/类
@Override
public void updateTextSize()
{
    super.updateTextSize();
    final int hsp = getFormulaList().getDimen().get(ScaledDimensions.Type.HOR_SYMBOL_PADDING);
    if (functionTerm != null)
    {
        if (functionType == FunctionType.SQRT_LAYOUT || functionType == FunctionType.NTHRT_LAYOUT)
        {
            functionTerm.setWidth(getFormulaList().getDimen().get(ScaledDimensions.Type.SMALL_SYMBOL_SIZE));
            functionTerm.setPadding(0, 0, 0, 0);
        }
        else if (functionType == FunctionType.CONJUGATE_LAYOUT)
        {
            functionTerm.setPadding(hsp, 0, hsp, 0);
        }
        else if (functionType == FunctionType.FUNCTION_INDEX)
        {
            functionTerm.setPadding(0, 0, 0, 0);
        }
        else
        {
            functionTerm.setPadding(0, 0, hsp, 0);
        }
    }
    if (functionType == FunctionType.NTHRT_LAYOUT)
    {
        View nthrtPoverLayout = layout.findViewById(R.id.nthrt_power_layout);
        if (nthrtPoverLayout != null)
        {
            nthrtPoverLayout.setPadding(hsp, 0, hsp, 0);
        }
    }
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:35,代码来源:FormulaTermFunction.java

示例9: addView

import android.view.View; //导入方法依赖的package包/类
/**
 * 添加SnackBar视图
 * <p>在{@link #show()}之后调用</p>
 *
 * @param layoutId 布局文件
 * @param params   布局参数
 */
public static void addView(@LayoutRes final int layoutId, @NonNull final ViewGroup.LayoutParams params) {
    final View view = getView();
    if (view != null) {
        view.setPadding(0, 0, 0, 0);
        Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) view;
        View child = LayoutInflater.from(view.getContext()).inflate(layoutId, null);
        layout.addView(child, -1, params);
    }
}
 
开发者ID:AriesHoo,项目名称:FastLib,代码行数:17,代码来源:SnackBarUtil.java

示例10: measureChild

import android.view.View; //导入方法依赖的package包/类
public void measureChild(View child) {
    final DeviceProfile grid = mLauncher.getDeviceProfile();
    final int cellWidth = mCellWidth;
    final int cellHeight = mCellHeight;
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
    if (!lp.isFullscreen) {
        // 把计算的结果封装到LayoutParams中,用于布局item的时候进行调用
        lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap, invertLayoutHorizontally(), mCountX);// 核心代码

        if (child instanceof LauncherAppWidgetHostView) {
            // Widgets have their own padding, so skip
        } else {
            // Otherwise, center the icon/folder
            int cHeight = getCellContentHeight();
            int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f));
            int cellPaddingX = (int) (grid.edgeMarginPx / 2f);
            child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0);
        }
    } else {
        lp.x = 0;
        lp.y = 0;
        lp.width = getMeasuredWidth();
        lp.height = getMeasuredHeight();
    }
    int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
    int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
    child.measure(childWidthMeasureSpec, childheightMeasureSpec);
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:29,代码来源:ShortcutAndWidgetContainer.java

示例11: setBackgroundKeepingPadding

import android.view.View; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void setBackgroundKeepingPadding(View view, Drawable drawable) {
    int[] padding = new int[]{view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()};
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(drawable);
    } else {
        view.setBackgroundDrawable(drawable);
    }
    view.setPadding(padding[0], padding[1], padding[2], padding[3]);
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:12,代码来源:QMUIViewHelper.java

示例12: setPadding

import android.view.View; //导入方法依赖的package包/类
/**
 * 增加View的paddingTop,增加的值为状态栏高度
 */
public static void setPadding(Context context, View view) {

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context),
        view.getPaddingRight(), view.getPaddingBottom());
  }
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:11,代码来源:SystemBarHelper.java

示例13: setPaddingRelative

import android.view.View; //导入方法依赖的package包/类
public void setPaddingRelative(View view, int start, int top, int end, int bottom) {
    view.setPadding(start, top, end, bottom);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:ViewCompat.java

示例14: hideAnimatedView

import android.view.View; //导入方法依赖的package包/类
public static void hideAnimatedView(View view) {
    if (PRE_HC && view != null)
        view.setPadding(view.getWidth(), 0, 0, 0);
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:5,代码来源:DeviceUtils.java

示例15: setTransparent

import android.view.View; //导入方法依赖的package包/类
public static void setTransparent(Activity activity, View needOffsetView) {

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            return;
        }

        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (contentView.getChildAt(0) == null) {
            return;
        }
        else if (contentView.getChildCount() > 1 && contentView.getChildAt(1) instanceof StatusBarView) {
            contentView.removeViewAt(1);
        }
        if (contentView.getChildAt(0) instanceof DrawerLayout) {
            // 让DrawerLayout中的布局内容可以延伸到状态栏
            // 为了实现上述效果,设置DrawerLayout以及两个子View的fitsSystemWindows为false
            // 这个带来了一个问题:
            // DrawerLayout的内容布局会从屏幕最上方开始绘制,
            // 所以需要下移避免被状态栏遮挡的布局,手动设置marginTop。
            DrawerLayout drawerLayout = (DrawerLayout) contentView.getChildAt(0);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
            } else {
                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            }

            ViewGroup drawerLayoutContent = (ViewGroup) drawerLayout.getChildAt(0);
            //如果DrawerLayout的内容布局第一个子View是我们自己的StatusBarView就将它reomve。
            if (drawerLayoutContent.getChildAt(0) instanceof StatusBarView) {
                drawerLayoutContent.removeViewAt(0);
            }

            View drawerLayoutContentReal = drawerLayoutContent.getChildAt(0);

            // 内容布局不是 LinearLayout 时,清除多余的StatusBarHeight。
            if (!(drawerLayoutContent instanceof LinearLayout) &&
                    drawerLayoutContentReal != null &&
                    drawerLayoutContentReal.getTag(R.id.tag_top) != null &&
                    drawerLayoutContentReal.getTag(R.id.tag_top).equals(TAG_ADD_TOP)) {
                drawerLayoutContentReal.setPadding(
                        drawerLayoutContentReal.getPaddingLeft(),
                        drawerLayoutContentReal.getPaddingTop() - getStatusBarHeight(activity),
                        drawerLayoutContentReal.getPaddingRight(),
                        drawerLayoutContentReal.getPaddingBottom()
                );
                drawerLayoutContentReal.setTag(R.id.tag_top, TAG_REMOVE_TOP);
            }

            // 设置属性
            setDrawerLayoutProperty(drawerLayout, drawerLayoutContent);

        } else if (contentView.getChildAt(0) instanceof CoordinatorLayout) {

            transparentStatusBar(activity);
            setRootViewPaddingTop(activity, PaddingTop.removePaddingTop);

        } else {
            transparentStatusBar(activity);

            ViewCompat.setFitsSystemWindows(contentView.getChildAt(0), false);
            ViewCompat.requestApplyInsets(contentView.getChildAt(0));
        }

        if (needOffsetView != null && needOffsetView.getTag(R.id.tag_need_offset) == null) {

            ViewGroup.MarginLayoutParams layoutParams =
                    (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
            layoutParams.setMargins(
                    layoutParams.leftMargin,
                    layoutParams.topMargin + getStatusBarHeight(activity),
                    layoutParams.rightMargin,
                    layoutParams.bottomMargin);

            needOffsetView.setTag(R.id.tag_need_offset, TAG_NEED_OFFNET);
        }
    }
 
开发者ID:ghnor,项目名称:StatusBarFits,代码行数:79,代码来源:StatusBarFits.java


注:本文中的android.view.View.setPadding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。