Example usage for android.widget TextView setPadding

List of usage examples for android.widget TextView setPadding

Introduction

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

Prototype

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

Source Link

Usage

From source file:com.google.android.apps.gutenberg.EulaFragment.java

@NonNull
@Override/*  w  w w  .  ja va2s .  com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int padding = getResources().getDimensionPixelSize(R.dimen.dialog_padding);
    TextView eulaTextView = new TextView(getActivity());
    eulaTextView.setText(Html.fromHtml(getString(R.string.eula_content)));
    eulaTextView.setMovementMethod(LinkMovementMethod.getInstance());
    eulaTextView.setPadding(padding, padding, padding, padding);
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.eula).setView(eulaTextView)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:de.marcelkapfer.morseconverter.DisplayMessageActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get the message from the intent
    Intent intent = getIntent();//from w  w  w. j  a  va2s.  c om
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

    // Create the text view
    TextView textView = new TextView(this);
    textView.setTextSize(20);
    textView.setText(message);
    textView.setTextIsSelectable(true);
    textView.setPadding(10, 10, 10, 10);

    // Set the text view as the activity layout
    setContentView(textView);
}

From source file:com.roy.test.ContentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);//from  w ww  .  j a  v a2 s  .co  m
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);
    text.setPadding(20, 20, 20, 20);

    LinearLayout layout = maker.addColLayout(false, maker.layFF(0));

    layout.setGravity(Gravity.CENTER);
    layout.addView(text);

    return layout;
}

From source file:com.alibaba.akita.samples.TestFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
        mContent = savedInstanceState.getString(KEY_CONTENT);
    }/*from w w w  .  ja  v a2 s  . c  om*/

    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);
    text.setPadding(20, 20, 20, 20);

    LinearLayout layout = new LinearLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER);
    layout.addView(text);

    return layout;
}

From source file:com.art2cat.dev.moonlightnote.controller.settings.CommonSettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    if (getArguments() != null) {
        mType = getArguments().getInt("type");
    }/*from   w w  w . j a  va  2 s. c o  m*/
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    linearLayout.setLayoutParams(params);
    ScrollView scrollView = new ScrollView(getActivity());
    scrollView.setLayoutParams(params);
    linearLayout.addView(scrollView);
    TextView textView = new TextView(getActivity());
    textView.setLayoutParams(params);
    int padding = getResources().getDimensionPixelOffset(R.dimen.padding);
    textView.setPadding(padding, padding, padding, padding);
    switch (mType) {
    case Constants.FRAGMENT_ABOUT:
        textView.setGravity(Gravity.CENTER);
        textView.setText(getContent());
        getActivity().setTitle(R.string.settings_about);
        break;
    case Constants.FRAGMENT_LICENSE:
        textView.setGravity(Gravity.CENTER);
        textView.setText(getContent());
        getActivity().setTitle(R.string.settings_license);
        break;
    case Constants.FRAGMENT_POLICY:
        textView.setGravity(Gravity.START);
        textView.setText(getContent());
        getActivity().setTitle(R.string.settings_policy);
        break;
    }
    setHasOptionsMenu(true);
    scrollView.addView(textView);
    return linearLayout;
}

From source file:com.commonsware.android.arXiv.arXiv.java

private boolean applyMenuChoice(MenuItem item) {
    switch (item.getItemId()) {
    case ABOUT_ID:
        String str = getString(R.string.about_text);
        TextView wv = new TextView(this);
        wv.setPadding(16, 0, 16, 16);
        wv.setText(str);//from  w w  w . j a  v  a2  s . c  o m

        ScrollView scwv = new ScrollView(this);
        scwv.addView(wv);

        Dialog dialog = new Dialog(this) {
            public boolean onKeyDown(int keyCode, KeyEvent event) {
                if (keyCode != KeyEvent.KEYCODE_DPAD_LEFT)
                    this.dismiss();
                return true;
            }
        };
        dialog.setTitle(R.string.about_arxiv_droid);
        dialog.addContentView(scwv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));
        dialog.show();
        return (true);
    case HISTORY_ID:
        Intent myIntent = new Intent(this, DownloadsActivity.class);
        startActivity(myIntent);
        return (true);
    case PREF_ID:
        if (Build.VERSION.SDK_INT >= 11) {
            startActivity(new Intent(this, EditPreferences.class));
        } else {
            startActivity(new Intent(this, EditPreferencesCompat.class));
        }
        return (true);
    case DONATE_ID:
        Intent goToMarket = new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=com.jd.android.arXiv"));
        try {
            startActivity(goToMarket);
        } catch (Exception ef) {
            Toast.makeText(this, "Market Not Installed", Toast.LENGTH_SHORT).show();
        }
        return (true);
    case SEARCH_ID:
        Intent search = new Intent(this, SearchWindow.class);
        startActivity(search);
        return (true);
    }
    return (false);
}

From source file:com.brookmanholmes.bma.wizard.ui.BaseChoiceFragment.java

protected void setTitle(View view) {
    ((TextView) view.findViewById(android.R.id.title)).setText(page.getTitle());

    if (getArguments().getInt(SingleChoiceFragment.ARG_TITLE_SIZE, -1) != -1) {
        TextView title = (TextView) view.findViewById(android.R.id.title);
        TextViewCompat.setTextAppearance(title, R.style.WizardPageTitle2);
        title.setPadding(0, 0, 0, 0);
    }//from ww  w. ja v a2 s  .  c  o  m
}

From source file:com.example.ahmed.ui.Welcome.InfoActivity.java

protected void showLicenseInfo() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("License information");

    TextView tv = new TextView(this);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setText(Html.fromHtml(getString(R.string.isc_license)));
    tv.setPadding(16, 12, 16, 0);
    alert.setView(tv);//from   w ww.j a va 2 s.  c om

    alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });
    alert.show();
}

From source file:com.pengfei.fastopen.adapter.SettingAdapter.java

@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild,
        View convertView, ViewGroup parent) {
    final Object child = list.get(groupPosition).childItems.get(childPosition);
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.item_dialog_item_child, parent, false);
    }/*from  ww w .jav  a2s. co m*/
    final TextView item = (TextView) convertView.findViewById(R.id.tv_item_child);
    item.setPadding(30, 10, 10, 10);
    if (child instanceof String && child.toString().endsWith(".apk")) {
        childExtraApk(convertView, child, item, groupPosition, childPosition);
    } else if (child instanceof SaveAppEntity) {
        childUninstallApp(convertView, groupPosition, childPosition, (SaveAppEntity) child, item);
    } else if (child instanceof LicenseEntity) {
        childLicense(convertView, (LicenseEntity) child, item);
    } else {
        item.setText(child.toString());
    }
    return convertView;
}

From source file:com.shafiq.mytwittle.view.PlaceholderPagerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
        mContent = savedInstanceState.getString(KEY_CONTENT);
    }//from w  ww .ja va2  s  .co m

    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);
    text.setPadding(20, 20, 20, 20);

    LinearLayout layout = new LinearLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER);
    layout.addView(text);

    setInitialDownloadState(InitialDownloadState.DOWNLOADED);

    return layout;
}