Example usage for android.widget ScrollView setPadding

List of usage examples for android.widget ScrollView setPadding

Introduction

In this page you can find the example usage for android.widget ScrollView setPadding.

Prototype

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

Source Link

Document

Sets the padding.

Usage

From source file:com.slushpupie.deskclock.ChangelogDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Standard AlertDialog does not support HTML-style links.
    // So rebuild the ScrollView->TextView with the appropriate
    // settings and set the view directly.
    TextView tv = new TextView(getActivity());
    tv.setPadding(5, 5, 5, 5);/*from   w w  w.j  av a  2 s.  c  o  m*/
    tv.setLinksClickable(true);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    tv.setText(R.string.changeLog);
    tv.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    ScrollView sv = new ScrollView(getActivity());
    sv.setPadding(14, 2, 10, 12);
    sv.addView(tv);
    builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle).setPositiveButton(R.string.ok,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ((DeskClock) getActivity()).acknoledgeChangelog();
                }
            });
    return builder.create();
}

From source file:net.gsantner.opoc.util.ActivityUtils.java

public void showDialogWithHtmlTextView(@StringRes int resTitleId, String text, boolean isHtml,
        DialogInterface.OnDismissListener dismissedListener) {
    ScrollView scroll = new ScrollView(_context);
    AppCompatTextView textView = new AppCompatTextView(_context);
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16,
            _context.getResources().getDisplayMetrics());

    scroll.setPadding(padding, 0, padding, 0);
    scroll.addView(textView);/*w w w  .  java  2s  .co m*/
    textView.setMovementMethod(new LinkMovementMethod());
    textView.setText(isHtml ? new SpannableString(Html.fromHtml(text)) : text);

    AlertDialog.Builder dialog = new AlertDialog.Builder(_context).setPositiveButton(android.R.string.ok, null)
            .setOnDismissListener(dismissedListener).setTitle(resTitleId).setView(scroll);
    dialog.show();
}

From source file:com.bhb27.isu.Props.java

private void EditProps(String[] props) {
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.setPadding(30, 20, 30, 20);

    TextView descriptionText = new TextView(getActivity());
    descriptionText.setText(getString(R.string.props_any_edit_dialog_summary));
    linearLayout.addView(descriptionText);

    ScrollView scrollView = new ScrollView(getActivity());
    scrollView.setPadding(0, 0, 0, 10);
    linearLayout.addView(scrollView);//from  w w  w. j  a v a  2s .c  om

    LinearLayout editLayout = new LinearLayout(getActivity());
    editLayout.setOrientation(LinearLayout.VERTICAL);
    scrollView.addView(editLayout);

    final AppCompatEditText[] EditProps = new AppCompatEditText[props.length];
    final AppCompatCheckBox[] ForceBP = new AppCompatCheckBox[props.length];
    final TextView[] descriptionAboveText = new TextView[props.length];
    final TextView[] descriptionBelowText = new TextView[props.length];

    for (int i = 0; i < props.length; i++) {
        descriptionAboveText[i] = new TextView(getActivity());
        descriptionAboveText[i].setText(String.format(getString(R.string.empty), props[i]));
        editLayout.addView(descriptionAboveText[i]);

        EditProps[i] = new AppCompatEditText(getActivity());
        EditProps[i].setText(Tools.getprop(props[i]));
        editLayout.addView(EditProps[i]);

        descriptionBelowText[i] = new TextView(getActivity());
        descriptionBelowText[i].setText(getString(R.string.props_any_edit_dialog_already_bp));
        ForceBP[i] = new AppCompatCheckBox(getActivity());
        ForceBP[i].setText(getString(R.string.props_any_edit_dialog_force_bp));

        if (Tools.PropIsinbp(props[i], getActivity()))
            editLayout.addView(descriptionBelowText[i]);
        else
            editLayout.addView(ForceBP[i]);
    }

    new AlertDialog.Builder(getActivity(), R.style.AlertDialogStyle)
            .setTitle(getString(R.string.props_any_edit_dialog_title)).setView(linearLayout)
            .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    return;
                }
            }).setPositiveButton(getString(R.string.apply), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int id) {
                    String finalmenssage = "\n", edited;
                    for (int i = 0; i < props.length; i++) {
                        edited = EditProps[i].getText().toString();
                        if (edited.isEmpty()) {
                            finalmenssage = finalmenssage
                                    + String.format(getString(R.string.edited_text_ro), props[i]);
                        } else if (edited.equals(Tools.getprop(props[i])))
                            finalmenssage = finalmenssage
                                    + String.format(getString(R.string.edited_text_equals), props[i]);
                        else {
                            if (((AppCompatCheckBox) ForceBP[i]).isChecked())
                                Tools.resetprop(executableFilePath, props[i], edited, getActivity(), true);
                            else
                                Tools.resetprop(executableFilePath, props[i], edited, getActivity(), false);
                            finalmenssage = finalmenssage
                                    + String.format(getString(R.string.edited_text_ok), props[i]);
                            save_prop(props[i], edited);
                        }
                        finalmenssage = finalmenssage + "\n";
                    }
                    finaldialogro(finalmenssage);
                    return;
                }
            }).show();
}

From source file:com.slushpupie.deskclock.DeskClock.java

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_CHANGELOG:

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        // Standard AlertDialog does not support HTML-style links.
        // So rebuild the ScrollView->TextView with the appropriate
        // settings and set the view directly.
        TextView tv = new TextView(this);
        tv.setPadding(5, 5, 5, 5);/*from w  ww. j a  v  a 2s  .co  m*/
        tv.setLinksClickable(true);
        tv.setMovementMethod(LinkMovementMethod.getInstance());
        tv.setText(R.string.changeLog);
        tv.setTextAppearance(this, android.R.style.TextAppearance_Medium);
        ScrollView sv = new ScrollView(this);
        sv.setPadding(14, 2, 10, 12);
        sv.addView(tv);
        builder.setView(sv).setCancelable(false).setTitle(R.string.changeLogTitle)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(DeskClock.this);
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.putBoolean("pref_changelog", false);
                        editor.putString("last_changelog", getString(R.string.app_version));
                        editor.commit();
                    }
                });
        return builder.create();
    default:
        return null;
    }
}