本文整理汇总了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);
}
}
}
示例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;
}
示例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);
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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]);
}
示例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());
}
}
示例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);
}
示例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);
}
示例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);
}
}