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


Java ViewGroup.setPadding方法代码示例

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


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

示例1: clearPreviousSetting

import android.view.ViewGroup; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:StatusBarUtil.java

示例2: clearPreviousSetting

import android.view.ViewGroup; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity)
{
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if(count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView)
    {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity
                .findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
 
开发者ID:Ayvytr,项目名称:EasyAndroid,代码行数:14,代码来源:BarTool.java

示例3: clearPreviousSetting

import android.view.ViewGroup; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
    if (fakeStatusBarView != null) {
        decorView.removeView(fakeStatusBarView);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
 
开发者ID:GuoZhaoHui628,项目名称:SliderStatusBar,代码行数:11,代码来源:StatusBarUtil.java

示例4: setColorForSwipeBack

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {
@Override
public void run() {
    coordinatorLayout.requestLayout();
}
   });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:39,代码来源:StatusBarUtil.java

示例5: setColorForSwipeBack

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, int color, int statusBarAlpha)
{
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    {
        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        contentView.setPadding(0, getStatusBarHeight(activity), 0, 0);
        contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        setTransparentForWindow(activity);
    }
}
 
开发者ID:Ayvytr,项目名称:EasyAndroid,代码行数:18,代码来源:BarTool.java

示例6: setColorForSwipeBack

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, int color, int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        contentView.setPadding(0, getStatusBarHeight(activity), 0, 0);
        contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        setTransparentForWindow(activity);
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:16,代码来源:BarUtils.java

示例7: setViewPadding

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 调整位置Padding
 * @param parent
 * @param background
 */
private void setViewPadding(ViewGroup parent, int background) {
    int[] rect = new int[4];
    rect[0] = parent.getPaddingLeft();
    rect[1] = parent.getPaddingTop();
    rect[2] = parent.getPaddingRight();
    rect[3] = parent.getPaddingBottom();
    parent.setBackgroundResource(background);
    parent.setPadding(rect[0], rect[1], rect[2], rect[3]);
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:15,代码来源:OverflowAdapter.java

示例8: setColorForSwipeBack

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
    @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {
                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
 
开发者ID:wheat7,项目名称:VRPlayer,代码行数:40,代码来源:StatusBarUtil.java

示例9: setContentTopPadding

import android.view.ViewGroup; //导入方法依赖的package包/类
static void setContentTopPadding(Activity activity, int padding) {
    ViewGroup mContentView = (ViewGroup) activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
    mContentView.setPadding(0, padding, 0, 0);
}
 
开发者ID:bigjelly,项目名称:AndFast,代码行数:5,代码来源:Eyes.java


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