I just started learning mobile development for Android and Jetpack Compose. I have a basic grasp on how to use Jetpack Compose but I was wondering if it is possible to create an offline map using Jetpack Compose?
As of today (2024, May 7), there is only an example for the “Runtime Layout” way of creating an offline map in the official mapbox sample code
I would like to try this way of writing but I am having difficulty in creating the databinding from the layout given below.
I only have a single entrypoint to my application, which is the default MainActivity.kt
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="10">
<FrameLayout
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="6" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="10">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="@string/style_pack"
android:textSize="12sp"
android:gravity="center"
/>
<ProgressBar
android:id="@+id/style_pack_download_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="8"
android:clickable="false"
android:indeterminate="false"
android:progressTint="@android:color/holo_orange_dark"
android:max="100" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:weightSum="10">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="center"
android:textSize="12sp"
android:text="@string/tile_region" />
<ProgressBar
android:id="@+id/tile_pack_download_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:layout_gravity="center"
android:clickable="false"
android:indeterminate="false"
android:progressTint="@android:color/holo_purple"
android:max="100" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:background="#97cdcfd3" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Gery is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2