Sets a view's left padding while retaining the padding from other sides - Android User Interface

Android examples for User Interface:View Padding

Description

Sets a view's left padding while retaining the padding from other sides

Demo Code


//package com.java2s;

import android.support.annotation.NonNull;

import android.view.View;

public class Main {
    /**/*from  ww  w.  ja  v  a2s  .  c o m*/
     * Sets a view's left padding while retaining the padding from other sides
     *
     * @param view       the input view
     * @param newPadding the new left padding in pixels
     */
    public static void setPaddingLeft(@NonNull View view, int newPadding) {
        view.setPadding(newPadding, view.getPaddingTop(),
                view.getPaddingRight(), view.getPaddingBottom());
    }
}

Related Tutorials