Как сделать ящик go над панелью действий? - PullRequest
1 голос
/ 19 марта 2020

Я добавил NavigationView в свой DrawerLayout. Проблема в том, что он идет под действием и статусной строкой. Я бы хотел, чтобы он был выше, предпочтительно, обоих баров, но я был бы рад получить его хотя бы над панелью действий.

enter image description here

Даже если цвет фона панели действий прозрачен, становится темнее при открытии ящика.

enter image description here

так выглядит моя основная деятельность в xml :

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
    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=".MainActivity"
    android:background="@drawable/background"
    android:fitsSystemWindows="true"
    android:id="@+id/drawerLayout"
    >

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/fragmentContainer"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/sideMenu"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@drawable/navigation_menu_background"
        app:menu="@menu/navigation_menu"
        />

</androidx.drawerlayout.widget.DrawerLayout>

и вот код Kotlin:

class MainActivity : AppCompatActivity() {
    private var playlistFragment = PlaylistFragment.newInstance()
    private var streamFragment = StreamFragment.newInstance()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
//        window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
        replaceFragment(playlistFragment)
        sideMenu.setNavigationItemSelectedListener { item ->
            handleNavigationItemTap(item)
            true
        }
    }

    private fun replaceFragment(fragment:Fragment){
        val fragmentTransaction = supportFragmentManager.beginTransaction()
        fragmentTransaction.replace(R.id.fragmentContainer, fragment)
        fragmentTransaction.commit()
    }

    private fun handleNavigationItemTap(item: MenuItem){
        when(item.itemId){
            R.id.playlistFragmentItem -> replaceFragment(playlistFragment)
            R.id.singleStreamItem -> replaceFragment(streamFragment)
        }
        drawerLayout.closeDrawer(GravityCompat.START)
    }
}
...