Java Code Examples for android.view.View.setPaddingRelative()

The following are Jave code examples for showing how to use setPaddingRelative() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: MiPushFramework   File: Utils.java   Source Code and License Vote up 6 votes
public static void forceCustomPadding(View view, boolean additive) {
    final Resources res = view.getResources();
    final int paddingSide = res.getDimensionPixelSize(R.dimen.settings_side_margin);

    final int paddingStart = paddingSide + (additive ? view.getPaddingStart() : 0);
    final int paddingEnd = paddingSide + (additive ? view.getPaddingEnd() : 0);
    final int paddingBottom = res.getDimensionPixelSize(
            R.dimen.preference_fragment_padding_bottom);

    view.setPaddingRelative(paddingStart, 0, paddingEnd, paddingBottom);
}
 
Example 2
Project: chromium-net-for-android   File: ApiCompatibilityUtils.java   Source Code and License Vote up 5 votes
/**
 * @see android.view.View#setPaddingRelative(int, int, int, int)
 */
public static void setPaddingRelative(View view, int start, int top, int end, int bottom) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        view.setPaddingRelative(start, top, end, bottom);
    } else {
        // Before JB MR1, all layouts are left-to-right, so start == left, etc.
        view.setPadding(start, top, end, bottom);
    }
}
 
Example 3
Project: silly-android   File: SillyAndroid.java   Source Code and License Vote up 5 votes
/**
 * Sets the top and bottom padding to the given View, keeping the horizontal padding values as the were.
 *
 * @param view    Which view to set the padding to, must not be {@code null}
 * @param padding The vertical padding value
 */
public static void setPaddingVertical(@NonNull final View view, @Px final int padding) {
    final int paddingStart = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? view.getPaddingStart() : view.getPaddingLeft();
    final int paddingEnd = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? view.getPaddingEnd() : view.getPaddingRight();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        view.setPaddingRelative(paddingStart, padding, paddingEnd, padding);
    } else {
        view.setPadding(paddingStart, padding, paddingEnd, padding);
    }
}
 
Example 4
Project: silly-android   File: SillyAndroid.java   Source Code and License Vote up 5 votes
/**
 * Sets the left/start and right/end padding to the given View, keeping the vertical padding values as the were.
 *
 * @param view    Which view to set the padding to, must not be {@code null}
 * @param padding The horizontal padding value
 */
public static void setPaddingHorizontal(@NonNull final View view, @Px final int padding) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        view.setPaddingRelative(padding, view.getPaddingTop(), padding, view.getPaddingBottom());
    } else {
        view.setPadding(padding, view.getPaddingTop(), padding, view.getPaddingBottom());
    }
}
 
Example 5
Project: letv   File: ViewCompatJellybeanMr1.java   Source Code and License Vote up 4 votes
public static void setPaddingRelative(View view, int start, int top, int end, int bottom) {
    view.setPaddingRelative(start, top, end, bottom);
}
 
Example 6
Project: AmenEye   File: ViewUtil.java   Source Code and License Vote up 4 votes
public static void setPaddingStart(View view, int paddingStart) {
    view.setPaddingRelative(paddingStart,
            view.getPaddingTop(),
            view.getPaddingEnd(),
            view.getPaddingBottom());
}
 
Example 7
Project: AmenEye   File: ViewUtil.java   Source Code and License Vote up 4 votes
public static void setPaddingTop(View view, int paddingTop) {
    view.setPaddingRelative(view.getPaddingStart(),
            paddingTop,
            view.getPaddingEnd(),
            view.getPaddingBottom());
}
 
Example 8
Project: AmenEye   File: ViewUtil.java   Source Code and License Vote up 4 votes
public static void setPaddingEnd(View view, int paddingEnd) {
    view.setPaddingRelative(view.getPaddingStart(),
            view.getPaddingTop(),
            paddingEnd,
            view.getPaddingBottom());
}
 
Example 9
Project: AmenEye   File: ViewUtil.java   Source Code and License Vote up 4 votes
public static void setPaddingBottom(View view, int paddingBottom) {
    view.setPaddingRelative(view.getPaddingStart(),
            view.getPaddingTop(),
            view.getPaddingEnd(),
            paddingBottom);
}
 
Example 10
Project: boohee_v5.6   File: ViewCompatJellybeanMr1.java   Source Code and License Vote up 4 votes
public static void setPaddingRelative(View view, int start, int top, int end, int bottom) {
    view.setPaddingRelative(start, top, end, bottom);
}
 
Example 11
Project: silly-android   File: SillyAndroid.java   Source Code and License Vote up 3 votes
/**
 * Sets the padding to the given View.
 *
 * @param view   Which view to set the padding to, must not be {@code null}
 * @param start  Start padding ('left' for old devices)
 * @param top    Top padding
 * @param end    End padding ('right' for old devices)
 * @param bottom Bottom padding
 */
public static void setPadding(@NonNull final View view, @Px final int start, @Px final int top, @Px final int end, @Px final int bottom) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        view.setPaddingRelative(start, top, end, bottom);
    } else {
        view.setPadding(start, top, end, bottom);
    }
}