
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> |
MainActivity.kt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
package net.hepteknoloji.myapplication import android.graphics.Color import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.text.Html import android.text.method.LinkMovementMethod import android.widget.TextView import androidx.core.text.HtmlCompat import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val Text = HtmlCompat.fromHtml("<a href=\"https://www.hepteknoloji.net\">İnternet Yayıncılığında Yeni Bir Soluk...<br>" + "hepTeknoloji.net</a>", HtmlCompat.FROM_HTML_MODE_LEGACY) txt.setMovementMethod(LinkMovementMethod.getInstance()) txt.setLinkTextColor(Color.BLUE) txt.setText(Text) } } |
href ( Hypertext REFerence): Hedef bağlantıyı ifade eder.
Metin içinde alt satıra geçmek için de <br> etkietini kullanabilirsiniz.
txt.setLinkTextColor(Color.BLUE) ile linkin rengini belirleyebilirsiniz.