Как изменяется размер действия в режиме жестов - PullRequest
0 голосов
/ 26 марта 2020

У меня есть простое приложение с ImageView внизу и popupWindow, расположенным над InageView. Вот мой код:

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val actionBar = supportActionBar
    actionBar!!.hide()
}

override fun onResume() {
    super.onResume()

    init()
}

private fun init() {
    val content = this.window.decorView.findViewById<ViewGroup>(android.R.id.content)

    content.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

    content.setOnApplyWindowInsetsListener { view, insets ->
        view.setPadding(0,insets.systemWindowInsetTop,0, insets.systemWindowInsetBottom)
        return@setOnApplyWindowInsetsListener insets.consumeSystemWindowInsets()
    }

    initToolTip()
}

private fun initToolTip() {
    var cl = findViewById<ConstraintLayout>(R.id.clContainer)
    val view = LayoutInflater.from(this).inflate(R.layout.custom_tool_tip, cl, false)

    var popupWindow = PopupWindow(
            view,
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT
    )
    popupWindow.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
    popupWindow.isOutsideTouchable = true

    val toolTipYLocation = 200
    val toolTipXLocation = 90
    // Display Tooltip

    Handler().postDelayed(Runnable {
        popupWindow.showAtLocation(cl, Gravity.BOTTOM or Gravity.END, toolTipXLocation, toolTipYLocation)
    }, 200)
}
}

Вот макет:

 <androidx.constraintlayout.widget.ConstraintLayout
     android:id="@+id/clContainer"
     android:layout_width="match_parent"
     android:layout_height="match_parent">

     <ImageView
         android:id="@+id/ivImageBottom"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@mipmap/ic_launcher"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent" />
 </androidx.constraintlayout.widget.ConstraintLayout>

Я запускаю его на своем MI9 с навигационным устройством, это выглядит так:

with navigation bar

и без панели навигации (в режиме жестов) это выглядит так:

without navigation bar

Есть ли способ обрабатывать вставки, чтобы заставить его работать? Я читал некоторые статьи о жестах, навигации и вставках ( ссылка ), но не понял этого

Спасибо

...