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.contralabs.inmap.fragments.LegalNoticesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();

    ScrollView scrollView = new ScrollView(context);
    // Set up the TextView
    final TextView message = new TextView(context);
    // We'll use a spannablestring to be able to make links clickable
    final SpannableString s = new SpannableString(
            GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(context));

    // Set some padding
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());
    message.setPadding(padding, padding, padding, padding);
    // Set up the final string
    message.setText(s);/* w  ww.  j av  a 2 s. c o  m*/
    scrollView.addView(message);
    // Now linkify the text
    Linkify.addLinks(message, Linkify.ALL);
    Linkify.addLinks(message, Pattern.compile("@([A-Za-z0-9_-]+)"), "https://twitter.com/#!/");
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.legal_notices).setCancelable(true)
            .setIcon(R.drawable.ic_launcher)
            .setPositiveButton(context.getString(R.string.voltar), (OnClickListener) null).setView(scrollView)
            .create();
}

From source file:com.github.wakhub.monodict.activity.settings.DownloadsActivity.java

@ItemClick(android.R.id.list)
void onClickListItem(int position) {
    final DownloadsItem item = listAdapter.getItem(position);
    TextView textView = new TextView(this);
    textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
    textView.setPadding((int) spaceRelax, (int) spaceRelax, (int) spaceRelax, (int) spaceRelax);
    textView.setText(String.format("%s\nsize: %s", item.getDescription(), item.getSize()));
    ScrollView scrollView = new ScrollView(this);
    scrollView.addView(textView);/*w  w  w.java 2 s.  c om*/

    new AlertDialog.Builder(this)
            .setPositiveButton(R.string.action_download, new AlertDialog.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    resultIntent.putExtra(RESULT_INTENT_ENGLISH, item.isEnglish());
                    resultIntent.putExtra(RESULT_INTENT_FILENAME, item.getName());
                    startDownload(item);
                }
            }).setNegativeButton(android.R.string.cancel, null).setIcon(R.drawable.ic_action_download)
            .setTitle(item.getName()).setView(scrollView).show();
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java

/**
 * ???tab?.//from  w w w  .j  a v  a 2  s .c  om
 *
 * @param left the left
 * @param top the top
 * @param right the right
 * @param bottom the bottom
 */
public void setTabPadding(int left, int top, int right, int bottom) {
    for (int i = 0; i < tabItemList.size(); i++) {
        TextView tv = tabItemList.get(i);
        tv.setPadding(left, top, right, bottom);
    }
}

From source file:com.numenta.taurus.instance.InstanceListActivity.java

private void configureSearchView(@NonNull final SearchView searchView) {
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    // Handle query events
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/*ww  w.  j  a  v a2  s . co m*/
        public boolean onQueryTextSubmit(String query) {
            // Hide Keyboard on submit
            InputMethodManager imm = (InputMethodManager) searchView.getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            if (imm != null) {
                imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
            }

            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            // Filter list as the user types
            _listFragment.applyFilter(newText);
            return true;
        }
    });

    // FIXME: Android does not support styling the search view across all versions.
    // For now, "peek" into internal API to make the appropriate changes to the SearchView.
    // In the future we should use the official android API to customize the SearchView widget.
    // See android.R.layout.search_view for the layout we are "peeking". It is no guarantee it
    // will work on all public android versions and/or OEM customizations.
    // This HACK is only valid for the POC phase. We should find a better solution before releasing
    Resources resources = searchView.getResources();

    // Style search box and text
    int searchPlateId = resources.getIdentifier("android:id/search_plate", null, null);
    View searchPlate = searchView.findViewById(searchPlateId);
    if (searchPlate != null) {
        int searchTextId = resources.getIdentifier("android:id/search_src_text", null, null);
        TextView searchText = (TextView) searchPlate.findViewById(searchTextId);
        if (searchText != null) {
            searchPlate.setBackgroundResource(android.R.drawable.editbox_background);
            searchText.setPadding(5, 0, 0, 0);
            searchText.setTextColor(Color.BLACK);
            searchText.setHintTextColor(Color.LTGRAY);
        }
    }
}

From source file:com.starwood.anglerslong.LicenseActivity.java

private void createTextView() {

    if (isCreateTextViewSet)
        return;/*from   www  . ja v  a2 s.c  om*/

    // Get the linear layout and set the parameters
    LinearLayout ll = (LinearLayout) findViewById(R.id.profile_ll);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;

    TextView createLicense = new TextView(this);
    createLicense.setId(0);
    createLicense.setText(Html.fromHtml(getResources().getString(R.string.create_license_string)));
    createLicense.setPadding(70, 100, 70, 100);
    createLicense.setTextSize(18);
    ll.addView(createLicense, params);
    isCreateTextViewSet = true;
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE TITLE ROW//  w  w  w .j  ava  2s. c  o  m
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleTitleRow(Map<String, String> att, LinearLayout linear) {
    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setMinimumHeight(30);
    container_layout
            .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo_blue));
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value_params);

    LinearLayout.LayoutParams ltext1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView t1 = new TextView(context);
    t1.setText(att.get("value"));
    t1.setTextSize(11);
    t1.setGravity(Gravity.CENTER_HORIZONTAL);
    t1.setPadding(2, 0, 0, 2);
    t1.setTextColor(Color.rgb(255, 255, 255));
    container_layout.addView(t1, ltext1);

    linear.addView(container_layout);
    return linear;
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * DOUBLE TITLE ROW//from  ww w . j a v  a 2s .  c o m
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getDoubleTitleRow(Map<String, String> att, LinearLayout linear) {
    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setMinimumHeight(30);
    container_layout
            .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo_blue));
    container_layout.setVerticalGravity(Gravity.CENTER);
    container_layout.setOrientation(LinearLayout.HORIZONTAL);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.3f);
    TextView tx = new TextView(context);
    tx.setText("");
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value_params);

    LinearLayout.LayoutParams ltext1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.35f);
    TextView t1 = new TextView(context);
    t1.setText(att.get("value1"));
    t1.setTextSize(11);
    t1.setGravity(Gravity.CENTER_HORIZONTAL);
    t1.setPadding(2, 0, 0, 2);
    t1.setTextColor(Color.rgb(255, 255, 255));
    container_layout.addView(t1, ltext1);

    LinearLayout.LayoutParams ltext2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.35f);
    TextView t2 = new TextView(context);
    t2.setText(att.get("value2"));
    t2.setTextSize(11);
    t2.setGravity(Gravity.CENTER_HORIZONTAL);
    t2.setPadding(2, 0, 0, 2);
    t2.setTextColor(Color.rgb(255, 255, 255));
    container_layout.addView(t2, ltext2);

    linear.addView(container_layout);
    return linear;
}

From source file:com.esri.arcgisruntime.sample.featurelayerupdateattributes.MainActivity.java

/**
 * Displays Callout//from  ww w.ja v a2 s .  c  o m
 * @param title the text to show in the Callout
 */
private void showCallout(String title) {

    // create a text view for the callout
    RelativeLayout calloutLayout = new RelativeLayout(getApplicationContext());

    TextView calloutContent = new TextView(getApplicationContext());
    calloutContent.setId(R.id.textview);
    calloutContent.setTextColor(Color.BLACK);
    calloutContent.setTextSize(18);
    calloutContent.setPadding(0, 10, 10, 0);

    calloutContent.setText(title);

    RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relativeParams.addRule(RelativeLayout.RIGHT_OF, calloutContent.getId());

    // create image view for the callout
    ImageView imageView = new ImageView(getApplicationContext());
    imageView.setImageDrawable(
            ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info_outline_black_18dp));
    imageView.setLayoutParams(relativeParams);
    imageView.setOnClickListener(new ImageViewOnclickListener());

    calloutLayout.addView(calloutContent);
    calloutLayout.addView(imageView);

    mCallout.setLocation(mMapView.screenToLocation(mClickPoint));
    mCallout.setContent(calloutLayout);
    mCallout.show();
}

From source file:br.org.funcate.dynamicforms.views.GSketchView.java

/**
 * @param noteId                the id of the note this image belows to.
 * @param fragmentDetail        the fragment detail  to use.
 * @param attrs                 attributes.
 * @param requestCode           the code for starting the activity with result.
 * @param parentView            parent/*from   w  w  w.j a v a2s  . co  m*/
 * @param label                 label
 * @param value                 value
 * @param constraintDescription constraints
 */
public GSketchView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs,
        final int requestCode, LinearLayout parentView, String label, String value,
        String constraintDescription) {
    super(fragmentDetail.getActivity(), attrs);
    this.noteId = noteId;

    _value = value;

    final FragmentActivity activity = fragmentDetail.getActivity();
    LinearLayout textLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(activity);
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription);
    textView.setTextColor(activity.getResources().getColor(R.color.formcolor));
    textLayout.addView(textView);

    final Button button = new Button(activity);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(15, 5, 15, 5);
    button.setText(R.string.draw_sketch);
    textLayout.addView(button);

    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            try {
                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
                double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences);

                Date currentDate = new Date();
                String sketchImageName = ImageUtilities.getSketchImageName(currentDate);

                File tempDir = ResourcesManager.getInstance(getContext()).getTempDir();
                File sketchFile = new File(tempDir, sketchImageName);
                /*
                 * open markers for new sketch
                 */
                MarkersUtilities.launch(fragmentDetail, sketchFile, gpsLocation, requestCode);
            } catch (Exception e) {
                //GPLog.error(this, null, e);
                Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
            }
        }
    });

    ScrollView scrollView = new ScrollView(activity);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, 150);
    scrollView.setLayoutParams(scrollLayoutParams);
    parentView.addView(scrollView);

    imageLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    imageLayout.setLayoutParams(imageLayoutParams);
    // imageLayout.setMinimumHeight(200);
    imageLayout.setOrientation(LinearLayout.HORIZONTAL);
    scrollView.addView(imageLayout);
    // scrollView.setFillViewport(true);

    try {
        refresh(activity);
    } catch (Exception e) {
        //GPLog.error(this, null, e);
        Toast.makeText(this.getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE IMAGE ROW/*from w  w  w .  ja  v a  2 s.co m*/
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f);
    ImageView img = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value"));
    img.setImageResource(context.getResources().getIdentifier(path, null, null));
    img.setPadding(0, 3, 0, 3);
    container_layout.addView(img, value_params);

    linear.addView(container_layout);
    return linear;
}