Example usage for android.view View setPadding

List of usage examples for android.view View setPadding

Introduction

In this page you can find the example usage for android.view View setPadding.

Prototype

public void setPadding(int left, int top, int right, int bottom) 

Source Link

Document

Sets the padding.

Usage

From source file:pl.kodujdlapolski.na4lapy.ui.drawer.DrawerActivityHandler.java

private void setDrawerHeader() {
    View headerView = navigationView.getHeaderView(0);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        headerView.setPadding(headerView.getPaddingLeft(),
                (int) (headerView.getPaddingTop() + activity.getResources().getDimension(R.dimen.status_bar)),
                headerView.getPaddingRight(), headerView.getPaddingBottom());
    }/*from   www.ja va2  s.c om*/
}

From source file:xyz.jamescarroll.genipass.Fragment.ExtFragment.java

protected View setPadding(View v) {
    TypedValue tv = new TypedValue();

    if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        v.setPadding(getDimension(R.dimen.activity_vertical_margin),
                TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics())
                        + getDimension(R.dimen.activity_horizontal_margin),
                getDimension(R.dimen.activity_vertical_margin),
                getDimension(R.dimen.activity_horizontal_margin));
    }/*  w ww.  j ava2s  . co m*/

    return v;
}

From source file:foam.starwisp.StarwispActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    //                             WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);//from  ww w  . ja v  a  2 s  .co  m
    //OuyaController.init(this);

    String arg = "none";
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        arg = extras.getString("arg");
    }

    String ori = "'portrait";
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        ori = "'landscape";
    }
    m_Scheme.eval("(set! screen-orientation " + ori + ")");

    String json = m_Scheme.eval("(activity-callback 'on-create \"" + m_Name + "\" (list \"" + arg + "\"))");
    View root = findViewById(R.id.main);

    root.setPadding(0, 0, 0, 0);

    m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/starwisp.ttf");
    //m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/grstylus.ttf");

    try {
        m_Builder.Build(this, m_Name, new JSONArray(json), (ViewGroup) root);
    } catch (JSONException e) {
        Log.e("starwisp", "Error parsing [" + json + "] " + e.toString());
    }
}

From source file:com.example.nikhil.wikipediasearch.ImageAdapter.java

public View getView(int position, View view, ViewGroup parent) {
    if (view == null) {
        view = new ImageView(parent.getContext());
        view.setPadding(6, 2, 6, 2);
        //view.getBackground().setColorFilter(Color.parseColor("#00ff00"), PorterDuff.Mode.DARKEN);
        view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.Color_1));

        view.invalidate();/*  w  ww .j  a v  a 2 s  .  c  om*/
    }

    int width = parent.getContext().getResources().getDisplayMetrics().widthPixels;
    if (URLS[position] != null) {
        Picasso.with(parent.getContext()).load(URLS[position]).noFade().resize(width / 4, width / 4)
                .centerCrop().error(R.drawable.no_image).placeholder(R.drawable.loading_image)
                .into((ImageView) view);
    }

    view.setTag(position);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                int pos = (int) v.getTag();
                zoomImageFromThumb(v, pos);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    return view;
}

From source file:com.jefftharris.passwdsafe.lib.AboutDialog.java

@SuppressLint("InflateParams")
@Override//from   www . ja va  2s  . co m
public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) {
    final String extraLicenseInfo = getArguments().getString("extraLicenses");

    Activity act = getActivity();
    LayoutInflater factory = LayoutInflater.from(act);
    View detailsView = factory.inflate(R.layout.fragment_about, null);
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int pad = (int) (dm.density * 6);
    detailsView.setPadding(pad, pad, pad, pad);

    View fileDetails = detailsView.findViewById(R.id.file_details_group);
    GuiUtils.setVisible(fileDetails, false);
    String name = updateAboutFields(detailsView, extraLicenseInfo, act);

    AlertDialog.Builder builder = new AlertDialog.Builder(act).setTitle(name)
            .setIcon(R.drawable.ic_action_info_dark).setView(detailsView)
            .setPositiveButton(R.string.close, this);
    return builder.create();
}

From source file:com.esminis.server.library.activity.DrawerFragment.java

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle state) {
    View view = super.onCreateView(inflater, container, state);
    if (view != null) {
        View viewList = view.findViewById(android.R.id.list);
        if (viewList != null) {
            viewList.setPadding(0, 0, 0, 0);
        }/*  w  ww .j  ava 2  s . c  o m*/
    }
    return view;
}

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

private void setDefaultPadding(View view) {
    view.setPadding(mSpacingDouble, mSpacingDouble, mSpacingDouble, mSpacingDouble);
}

From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.DistanceDialogFragment.java

@SuppressLint("InflateParams")
@Override//from ww  w .j  a  v  a2 s .  com
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getCompatContext();
    AlertDialog dialog = new AlertDialog.Builder(ctx)
            .setTitle(getResources().getString(R.string.careerstack_dialog_distance_title))
            .setPositiveButton(android.R.string.ok, this).setNegativeButton(android.R.string.cancel, this)
            .create(); //create basic dialog

    //insert custom views
    View content = View.inflate(ctx, R.layout.viewstub_distance_seekbar, null);
    initViews(content); //preload views

    Resources r = getResources();
    content.setPadding(r.getDimensionPixelSize(R.dimen.dialog_margins),
            r.getDimensionPixelSize(R.dimen.dialog_margins), r.getDimensionPixelSize(R.dimen.dialog_margins),
            r.getDimensionPixelSize(R.dimen.dialog_margins));
    dialog.setView(content);
    onValueUpdate(currentDistanceValue);
    return dialog;
}

From source file:sg.fxl.topeka.widget.quiz.AbsQuizView.java

private void setDefaultPadding(View view) {
    view.setPadding(spacingDouble, spacingDouble, spacingDouble, spacingDouble);
}

From source file:ooo.oxo.apps.earth.widget.WindowInsetsFrameLayout.java

@TargetApi(19)
private boolean applySystemWindowInsets19(Rect insets) {
    boolean consumed = false;

    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);

        if (!child.getFitsSystemWindows()) {
            continue;
        }/*from   w  ww  .  j  a v  a 2s .  c  o m*/

        Rect childInsets = new Rect(insets);

        computeInsetsWithGravity(child, childInsets);

        child.setPadding(childInsets.left, childInsets.top, childInsets.right, childInsets.bottom);

        consumed = true;
    }

    return consumed;
}