Example usage for android.view ViewGroup getPaddingRight

List of usage examples for android.view ViewGroup getPaddingRight

Introduction

In this page you can find the example usage for android.view ViewGroup getPaddingRight.

Prototype

public int getPaddingRight() 

Source Link

Document

Returns the right padding of this view.

Usage

From source file:com.gosuncn.core.util.view.StatusBarUtils.java

/**
 * DrawerLayout ???//w ww  . j  a  v  a  2 s  .c  o  m
 *
 * @param activity       ?activity
 * @param drawerLayout   DrawerLayout
 * @param color          ??
 * @param statusBarAlpha ???
 */
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color,
        int statusBarAlpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    // ????
    //  statusBarView 
    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) {
        contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
    } else {
        StatusBarView statusBarView = createStatusBarView(activity, color);
        contentLayout.addView(statusBarView, 0);
    }
    // ? LinearLayout ,padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1).setPadding(contentLayout.getPaddingLeft(),
                getStatusBarHeight(activity) + contentLayout.getPaddingTop(), contentLayout.getPaddingRight(),
                contentLayout.getPaddingBottom());
    }
    // 
    ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
    drawerLayout.setFitsSystemWindows(false);
    contentLayout.setFitsSystemWindows(false);
    contentLayout.setClipToPadding(true);
    drawer.setFitsSystemWindows(false);

    addTranslucentView(activity, statusBarAlpha);
}

From source file:org.huxizhijian.sdk.util.StatusBarUtil.java

/**
 * DrawerLayout ???/*from www .j a va 2 s  .  c  o m*/
 *
 * @param activity       ?activity
 * @param drawerLayout   DrawerLayout
 * @param color          ??
 * @param statusBarAlpha ???
 */
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color,
        int statusBarAlpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    // ????
    //  statusBarView 
    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    if (contentLayout.getChildCount() > 0 && contentLayout.getChildAt(0) instanceof StatusBarView) {
        contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
    } else {
        StatusBarView statusBarView = createStatusBarView(activity, color);
        contentLayout.addView(statusBarView, 0);
    }
    // ? LinearLayout ,padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1).setPadding(contentLayout.getPaddingLeft(),
                getStatusBarHeight(activity) + contentLayout.getPaddingTop(), contentLayout.getPaddingRight(),
                contentLayout.getPaddingBottom());
    }
    // 
    ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
    drawerLayout.setFitsSystemWindows(false);
    contentLayout.setFitsSystemWindows(false);
    contentLayout.setClipToPadding(true);
    drawer.setFitsSystemWindows(false);

    addTranslucentView(activity, statusBarAlpha);
}

From source file:org.gateshipone.odyssey.viewitems.ListViewItem.java

/**
 * Base constructor to create a non section-type element.
 *
 * @param context  The current context./*from  w ww.j  a  v  a  2s.c o  m*/
 * @param showIcon If the icon of the item should be shown. It is not changeable after creation.
 * @param adapter  The scroll speed adapter for cover loading.
 */
private ListViewItem(final Context context, final boolean showIcon, final ScrollSpeedAdapter adapter) {
    super(context, R.layout.listview_item_file, 0, 0, adapter);

    mTitleView = (TextView) findViewById(R.id.item_title);
    mSubtitleView = (TextView) findViewById(R.id.item_subtitle);
    mAdditionalSubtitleView = (TextView) findViewById(R.id.item_additional_subtitle);
    mIconView = (ImageView) findViewById(R.id.item_icon);

    if (showIcon) {
        mIconView.setVisibility(VISIBLE);
        ViewGroup basicItemLayout = (ViewGroup) findViewById(R.id.basic_listview_item);
        basicItemLayout.setPadding(0, 0, basicItemLayout.getPaddingRight(), 0);
    } else {
        mIconView.setVisibility(GONE);
    }
}

From source file:com.efan.notlonely_android.view.PagerSlidingTabStrip.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (allowWidthFull && tabsLayout != null) {
        View childView;/*from  w  ww  .  j  a va 2  s.co m*/
        for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) {
            childView = tabsLayout.getChildAt(w);
            ViewGroup.LayoutParams params = childView.getLayoutParams();
            params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            childView.setLayoutParams(params);
        }
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (!allowWidthFull) {
        return;
    }
    ViewGroup tabsLayout = getTabsLayout();
    if (tabsLayout == null) {
        return;
    }
    if (tabsLayout.getChildCount() <= 0) {
        return;
    }

    if (tabViews == null) {
        tabViews = new ArrayList<View>();
    } else {
        tabViews.clear();
    }
    for (int w = 0; w < tabsLayout.getChildCount(); w++) {
        tabViews.add(tabsLayout.getChildAt(w));
    }

    adjustChildWidthWithParent(tabViews,
            getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec,
            heightMeasureSpec);

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

From source file:jahirfiquitiva.iconshowcase.activities.AltWallpaperViewerActivity.java

private void showNotConnectedSnackBar() {
    Snackbar notConnectedSnackBar = Utils.snackbar(this, layout, getString(R.string.no_conn_title),
            Snackbar.LENGTH_LONG);//from w  w w  .jav a  2  s  . c om

    ViewGroup snackbarView = (ViewGroup) notConnectedSnackBar.getView();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        snackbarView.setPadding(snackbarView.getPaddingLeft(), snackbarView.getPaddingTop(),
                snackbarView.getPaddingRight(), Utils.getNavigationBarHeight(this));
    }
    notConnectedSnackBar.show();
}

From source file:com.android.yijiang.kzx.widget.tab.PagerSlidingTabStrip.java

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    ViewGroup tabViewGroup = getTabsLayout();

    // /*from   w w w  . j  a v  a  2 s  .  co m*/
    if (tabViewGroup == null || tabViewGroup.getChildCount() <= 0) {
        super.onLayout(changed, l, t, r, b);
        return;
    }

    int viewWidth = r - l;

    // Item
    if ((measure(tabViewGroup).getMeasuredWidth() < viewWidth) && allowWidthFull) {
        // ?tabViewGroup??
        viewWidth -= tabViewGroup.getPaddingLeft();
        viewWidth -= tabViewGroup.getPaddingRight();
        if (tabViewGroup.getLayoutParams() instanceof MarginLayoutParams) {
            MarginLayoutParams tabsLayoutParams = (MarginLayoutParams) tabViewGroup.getLayoutParams();
            viewWidth -= tabsLayoutParams.leftMargin;
            viewWidth -= tabsLayoutParams.rightMargin;
        }

        // ??Tab?
        View tabView;
        for (int w = 0; w < tabViewGroup.getChildCount(); w++) {
            tabView = tabViewGroup.getChildAt(w);
            if (tabView.getLayoutParams() instanceof MarginLayoutParams) {
                MarginLayoutParams marginLayoutParams = (MarginLayoutParams) tabView.getLayoutParams();
                viewWidth -= marginLayoutParams.leftMargin;
                viewWidth -= marginLayoutParams.rightMargin;
            }
        }

        // ?
        int averageWidth = viewWidth / tabViewGroup.getChildCount();
        int bigTabCount = 0; // ?tab???
        for (int w = 0; w < tabViewGroup.getChildCount(); w++) {
            tabView = tabViewGroup.getChildAt(w);
            // ????
            if (tabView != null && tabView.getMeasuredWidth() > averageWidth) {
                viewWidth -= tabView.getMeasuredWidth();
                bigTabCount++;
            }
        }

        // ?
        averageWidth = viewWidth / (tabViewGroup.getChildCount() - bigTabCount);

        // ??Item
        for (int w = 0; w < tabViewGroup.getChildCount(); w++) {
            //?????
            tabView = tabViewGroup.getChildAt(w);
            if (tabView != null) {
                ViewGroup.LayoutParams layoutParams = tabView.getLayoutParams();
                if (layoutParams != null) {
                    layoutParams.width = tabView.getMeasuredWidth() < averageWidth ? averageWidth
                            : tabView.getMeasuredWidth();
                    tabView.setLayoutParams(layoutParams);
                    measure(tabView);
                }
            }
        }
        measure(tabViewGroup);
    }

    // ?????
    currentPosition = viewPager != null ? viewPager.getCurrentItem() : 0;
    scrollToChild(currentPosition, 0); //??
    selectedTab(currentPosition); //?TAB

    //?tab?Pager
    for (int w = 0; w < tabViewGroup.getChildCount(); w++) {
        View itemView = tabViewGroup.getChildAt(w);
        itemView.setTag(w);
        itemView.setOnClickListener(this);
    }

    super.onLayout(changed, l, t, r, b);
}

From source file:com.lgh.tool.myview.PagerSlidingTabStrip.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (allowWidthFull && tabsLayout != null) {
        View childView;//from  w ww. j a  va 2 s .  c o  m
        for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) {
            childView = tabsLayout.getChildAt(w);
            ViewGroup.LayoutParams params = childView.getLayoutParams();
            params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            childView.setLayoutParams(params);
        }
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (!allowWidthFull) {
        return;
    }
    ViewGroup tabsLayout = getTabsLayout();
    if (tabsLayout == null) {
        return;
    }
    if (tabsLayout.getChildCount() <= 0) {
        return;
    }

    if (tabViews == null) {
        tabViews = new ArrayList<View>();
    } else {
        tabViews.clear();
    }
    for (int w = 0; w < tabsLayout.getChildCount(); w++) {
        tabViews.add(tabsLayout.getChildAt(w));
    }

    adjustChildWidthWithParent(tabViews,
            getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec,
            heightMeasureSpec);

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

From source file:com.ststudy.client.android.ui.pagerslidingtabstrip.PagerSlidingTabStrip.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (allowWidthFull && tabsLayout != null) {
        View childView;/*from w w w.j av  a 2 s  .  c o  m*/
        for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) {
            childView = tabsLayout.getChildAt(w);
            ViewGroup.LayoutParams params = childView.getLayoutParams();
            params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            childView.setLayoutParams(params);
        }
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (!allowWidthFull) {
        return;
    }
    ViewGroup tabsLayout = getTabsLayout();
    if (tabsLayout == null) {
        return;
    }
    if (tabsLayout.getChildCount() <= 0) {
        return;
    }

    if (tabViews == null) {
        tabViews = new ArrayList<>();
    } else {
        tabViews.clear();
    }
    for (int w = 0; w < tabsLayout.getChildCount(); w++) {
        tabViews.add(tabsLayout.getChildAt(w));
    }

    adjustChildWidthWithParent(tabViews,
            getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec,
            heightMeasureSpec);

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (!allowWidthFull)
        return;//  w  w w. j av a 2 s . co  m
    ViewGroup tabsLayout = getTabsLayout();
    if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth())
        return;
    if (tabsLayout.getChildCount() <= 0)
        return;

    if (tabViews == null) {
        tabViews = new ArrayList<View>();
    } else {
        tabViews.clear();
    }
    for (int w = 0; w < tabsLayout.getChildCount(); w++) {
        tabViews.add(tabsLayout.getChildAt(w));
    }

    adjustChildWidthWithParent(tabViews,
            getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec,
            heightMeasureSpec);

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

From source file:jahirfiquitiva.iconshowcase.activities.AltWallpaperViewerActivity.java

private void saveWallpaper(final Activity context, final String wallName, final MaterialDialog downloadDialog,
        final Bitmap result) {
    downloadDialog.setContent(context.getString(R.string.saving_wallpaper));
    new Thread(new Runnable() {
        @Override//from  ww  w .  j  av  a 2 s .c  o  m
        public void run() {
            if (mPrefs.getDownloadsFolder() != null) {
                downloadsFolder = new File(mPrefs.getDownloadsFolder());
            } else {
                downloadsFolder = new File(context.getString(R.string.walls_save_location,
                        Environment.getExternalStorageDirectory().getAbsolutePath()));
            }
            //noinspection ResultOfMethodCallIgnored
            downloadsFolder.mkdirs();
            final File destFile = new File(downloadsFolder, wallName + ".png");
            String snackbarText;
            if (!destFile.exists()) {
                try {
                    result.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(destFile));
                    snackbarText = context.getString(R.string.wallpaper_downloaded, destFile.getAbsolutePath());
                } catch (final Exception e) {
                    snackbarText = context.getString(R.string.error);
                }
            } else {
                snackbarText = context.getString(R.string.wallpaper_downloaded, destFile.getAbsolutePath());
            }
            final String finalSnackbarText = snackbarText;
            context.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    downloadDialog.dismiss();
                    Snackbar longSnackbar = Utils.snackbar(AltWallpaperViewerActivity.this, layout,
                            finalSnackbarText, Snackbar.LENGTH_LONG);
                    ViewGroup snackbarView = (ViewGroup) longSnackbar.getView();
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                        snackbarView.setPadding(snackbarView.getPaddingLeft(), snackbarView.getPaddingTop(),
                                snackbarView.getPaddingRight(),
                                Utils.getNavigationBarHeight(AltWallpaperViewerActivity.this));
                    }
                    longSnackbar.show();
                    longSnackbar.setCallback(new Snackbar.Callback() {
                        @Override
                        public void onDismissed(Snackbar snackbar, int event) {
                            super.onDismissed(snackbar, event);
                            reshowFab(fab);
                            setupFullScreen();
                        }
                    });
                }
            });
        }
    }).start();
}