Joshua
08/09/2020, 11:47 AM<TextView
android:id="@+id/textView6"
android:layout_width="273dp"
android:layout_height="45dp"
android:layout_marginStart="32dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="32dp"
android:autoLink="web"
android:fontFamily="@font/avenir_next_regular"
android:text="@string/terms_and_conditions"
android:textAlignment="center"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3" />
<string name="terms_and_conditions">By tapping Sign in, you agree to our <a href="<http://www.google.com>" target="_top">Terms</a>. Learn how we process your data in our Privacy Policy and Cookies Policy.</string>
brandonmcansh
08/09/2020, 1:05 PMrhenley
08/09/2020, 1:10 PMrhenley
08/09/2020, 1:16 PMJoshua
08/09/2020, 2:37 PMJoshua
08/09/2020, 2:37 PMJoshua
08/09/2020, 2:45 PMJoshua
08/09/2020, 2:51 PMoverride fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
textView6.movementMethod = LinkMovementMethod.getInstance()
textView6.linksClickable = true
}
rhenley
08/09/2020, 2:56 PMtextView6.text( Html.fromHtml( R.string.terms_and_conditions ) );
textView6.setMovementMethod(LinkMovementMethod.getInstance());
and omit textView6.linksClickable = true.
That's one solution proposed in the StackOverflow article linked above.
But this is why I use Spannables. Lots of stackoverflow about movementMethod being flaky. Spannables are a pain, but they work.Joshua
08/09/2020, 3:06 PMtextView6.text = Html.fromHtml(123.toString(),0)
textView6.movementMethod = LinkMovementMethod.getInstance()
This does not work:
textView6.text = Html.fromHtml(resources.getString(R.string.terms_and_conditions),0)
textView6.movementMethod = LinkMovementMethod.getInstance()
vgonda
08/09/2020, 3:16 PMrhenley
08/09/2020, 3:21 PMtextView6.text = Html.fromHtml("This <a href="<https://www.google.com>">Google</a>)
. This test removes getText/getString complications temporarily.
But @vgonda is right -- unless you really need rich text, make the whole string clickable.rhenley
08/09/2020, 3:22 PMJoshua
08/09/2020, 3:30 PMtextView6.text = Html.fromHtml("This <a href="<https://www.google.com>">Google</a>)
Joshua
08/09/2020, 3:36 PMandroid:autoLink="web"
in your layout OR:
TextView link = (TextView) findViewById(R.id.link);
link.setMovementMethod(LinkMovementMethod.getInstance());