Example usage for android.graphics Paint UNDERLINE_TEXT_FLAG

List of usage examples for android.graphics Paint UNDERLINE_TEXT_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint UNDERLINE_TEXT_FLAG.

Prototype

int UNDERLINE_TEXT_FLAG

To view the source code for android.graphics Paint UNDERLINE_TEXT_FLAG.

Click Source Link

Document

Paint flag that applies an underline decoration to drawn text.

Usage

From source file:Main.java

public static void setHtmlLink(TextView tvTest) {
    tvTest.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
    tvTest.getPaint().setAntiAlias(true);
}

From source file:Main.java

public static void addUnderlineTextView(TextView tv) {
    tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
}

From source file:Main.java

public static void setUnderlineStr(TextView tv, String str) {
    tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
    tv.setText(str);
}

From source file:Main.java

/**
 * This method formats a TextView as if it was a hyperlink. This method
 * is useful when it's not a real HTML link but there's an OnClickListener
 * assigned to the TextView, taking you to some other action.
 *
 * @param t The TextView whose appearance is to be changed.
 */// ww  w.  j a va2s. c o m
public static TextView renderAsLink(TextView t) {
    t.setPaintFlags(t.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    t.setTextColor(Color.BLUE);
    return t;
}

From source file:Main.java

public static void setUnderLine(TextView tv) {
    if (tv.getText() != null) {
        String udata = tv.getText().toString();
        SpannableString content = new SpannableString(udata);
        content.setSpan(new UnderlineSpan(), 0, udata.length(), 0);
        tv.setText(content);/*  www .j  ava2 s  .c om*/
        content.setSpan(new UnderlineSpan(), 0, udata.length(), 0);
    } else {
        tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
    }
}

From source file:Main.java

public static void setTVUnderLine(TextView textView) {
    textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
    textView.getPaint().setAntiAlias(true);
}

From source file:com.ouyangzn.github.utils.UiUtils.java

/**
 * textView//from   w w w  .  j  a  v  a 2  s.c  om
 *
 * @param textView TextView
 */
public static void addUnderLine(TextView textView) {
    textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
}

From source file:eu.inmite.apps.smsjizdenka.framework.about.BaseAboutFragment.java

public static void setupLink(TextView textView, View.OnClickListener listener) {
    textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    textView.setTextColor(App.getInstance().getResources().getColorStateList(R.color.about_link_dark));
    textView.setOnClickListener(listener);
}

From source file:com.skyousuke.ivtool.view.HintSpinnerAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.simple_spinner, parent, false);
    }/*  w  ww.j a v a2  s. c  om*/
    TextView text = ViewHolder.get(convertView, R.id.simple_spinner_text);
    Object item = getItem(position);
    text.setText(item.toString());
    if (isEqualHint(item)) {
        text.setPaintFlags(text.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        text.setTextColor(ContextCompat.getColor(context, R.color.dark_gray));
    } else {
        if (color == ContextCompat.getColor(context, R.color.dark_yellow)) {
            TextViewCompat.setTextAppearance(text, R.style.ShadowText);
        } else
            TextViewCompat.setTextAppearance(text, R.style.NoShadowText);
        text.setTextColor(color);
    }
    return convertView;
}

From source file:org.mozilla.focus.widget.TelemetrySwitchPreference.java

@Override
protected void onBindView(final View view) {
    super.onBindView(view);

    final Switch switchWidget = view.findViewById(R.id.switch_widget);

    switchWidget.setChecked(TelemetryWrapper.isTelemetryEnabled(getContext()));

    switchWidget.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override//from  w w w .j a  v  a2s  . co m
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            TelemetryWrapper.setTelemetryEnabled(getContext(), isChecked);
        }
    });

    final Resources resources = view.getResources();

    final TextView summary = view.findViewById(android.R.id.summary);
    summary.setText(resources.getString(R.string.preference_mozilla_telemetry_summary2,
            resources.getString(R.string.app_name)));

    final TextView learnMoreLink = view.findViewById(R.id.link);
    learnMoreLink.setPaintFlags(learnMoreLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    learnMoreLink.setTextColor(ContextCompat.getColor(view.getContext(), R.color.colorAction));
    learnMoreLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // This is a hardcoded link: if we ever end up needing more of these links, we should
            // move the link into an xml parameter, but there's no advantage to making it configurable now.
            final String url = SupportUtils.getSumoURLForTopic(getContext(), "usage-data");
            final String title = getTitle().toString();

            final Intent intent = InfoActivity.getIntentFor(getContext(), url, title);
            getContext().startActivity(intent);
        }
    });

    final TypedArray backgroundDrawableArray = view.getContext()
            .obtainStyledAttributes(new int[] { R.attr.selectableItemBackground });
    final Drawable backgroundDrawable = backgroundDrawableArray.getDrawable(0);
    backgroundDrawableArray.recycle();
    learnMoreLink.setBackground(backgroundDrawable);

    // We still want to allow toggling the pref by touching any part of the pref (except for
    // the "learn more" link)
    setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            switchWidget.toggle();
            return true;
        }
    });
}