1.WebView를 띄울 Activity 만들기
xml
<?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=".setting.PrivacyActivity">
<WebView
android:id="@+id/wv_privacy"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
2. Kotlin 코드에서 url 연결
class PrivacyActivity : AppCompatActivity() {
private lateinit var binding: ActivityPrivacyBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityPrivacyBinding.inflate(layoutInflater)
setContentView(binding.root)
// binding.wvPrivacy.webViewClient = WebViewClient()
// binding.wvPrivacy.loadUrl("https://warmdeveloper.tistory.com/46")
binding.wvPrivacy.apply {
webViewClient = WebViewClient()
loadUrl("https://warmdeveloper.tistory.com/46")
}
}
}
'개발 공부 > Android' 카테고리의 다른 글
[Android Kotlin]ViewBinding과 DataBinding 차이 & Databinding 적용하기 (0) | 2022.09.26 |
---|---|
[Android/이슈 해결] 앱 출시 이후 Retrofit 작동을 하지 않음 (0) | 2022.09.24 |
[Android Kotlin] Clipboard 복사 기능 구현하기(copy) (0) | 2022.09.02 |
[Android Kotlin] Firebase Crashlytics적용하기 (2) | 2022.09.01 |
[Android Kotlin] AdMob 광고단위 생성 및 Android 앱에 전면광고 넣기 (2) | 2022.08.24 |