Reputation: 3221
I have a Clickable textview in between of multiple informative textviews(which are non - interactable).
Is there any android property or UI guideline to display clickable textview. So that user will get it immediately after seeing the textview that its clickable. Any other suggestions are welcome.
I tried giving blue color to the textView as in webpage hyperlinks, it looks bad as my background is also bluish.
Upvotes: 4
Views: 1008
Reputation: 7023
You Can use SpannAbleString for This if you want to do it programatically and If you want to do it Using UI then Create a Selector for Text for SpanAble String Sample Snippet is Following
SpannableString spanScan3;
spanScan3=new SpannableString("or register manually");
ClickableSpan myActivityLauncher = new ClickableSpan() {
public void onClick(View view) {
Intent intent=new Intent (getApplicationContext(),ManualRegistration.class);
startActivity(intent);
}
};
spanScan3.setSpan(myActivityLauncher, 12, 20, 0);
spanScan3.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.light_green)), 12, 20, 0);
spanScan3.setSpan(new UnderlineSpan(), 12, 20, 0);
Scan_text_3.setText(spanScan3,BufferType.SPANNABLE);
and if you want o give color Using UI here is Sample make color folder in res Directory and in Color foldr make an xml name Like textColor.xml and in Xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="@color/whiteColor"></item>
<item android:color="@color/bluetxt"></item>
</selector>
do soe thing like this and give its refrence to your textView
Upvotes: 6
Reputation: 7626
Use color watever u want in the below line:
<YourTextView>.setText(Html.fromHtml("<u><FONT COLOR=\"#736AAA\" >"+String+"</Font></u>"));
Upvotes: 2