我在多个信息性文本视图之间有一个可点击的文本视图(不可交互)。
是否有任何Android属性或UI指南可显示可点击的textview。因此,用户将在看到可点击的textview后立即获取它。 欢迎任何其他建议。
我尝试将蓝色添加到textView中,就像在网页超链接中一样,它看起来很糟糕,因为我的背景也是偏蓝的。
答案 0 :(得分:6)
如果要以编程方式执行此操作,可以使用SpannAbleString,如果要执行此操作,请使用UI然后为文本创建选择器 for SpanAble String Sample Snippet正在关注
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);
如果你想要给出颜色使用UI这里是Sample 在res目录中制作颜色文件夹 并在Color foldr中创建一个xml名称,如textColor.xml 并在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>
做这样的事情并将其引用到你的textView
答案 1 :(得分:2)
在下面一行中使用您想要的颜色:
<YourTextView>.setText(Html.fromHtml("<u><FONT COLOR=\"#736AAA\" >"+String+"</Font></u>"));