0

I create a blank jet compose app on Wear OS. I want to enable edge swipe for exit app with left to right gest because i use pan on my app. I follow the procedure that can be seen [here][1], but it does not work. Here is my code with MainActivity.kt and main_activity.xml.

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            //WearApp("Android")
            setContentView(R.layout.activity_main)
            val swipeLayout  = findViewById<SwipeDismissFrameLayout>(R.id.swipe_dismiss_root)
            swipeLayout.addCallback(object : SwipeDismissFrameLayout.Callback() {
                override fun onDismissed(layout: SwipeDismissFrameLayout) {
                    layout.visibility = View.GONE
                }
            })
        }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<androidx.wear.widget.SwipeDismissFrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/swipe_dismiss_root" >

    <TextView
        android:id="@+id/test_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Swipe me to dismiss me." />
</androidx.wear.widget.SwipeDismissFrameLayout>

An idea. Thank you. [1]: https://developer.android.com/training/wearables/views/exit

Cyrille Mouret
  • 75
  • 1
  • 1
  • 5

0 Answers0