<layout xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
</layout>
android {
...
buildFeatures {
viewBinding true
}
}
kotlinCopy code
android {
...
buildFeatures {
viewBinding true
}
}
Kotlin code:
import com.example.mapapp.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Inflating the layout
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
// Now you can use binding to access the views defined in your XML file
}
}