Java MaterialCardView位于NavigationView前面。我怎样才能把它送回去?[安卓工作室]
我在我的Java MaterialCardView位于NavigationView前面。我怎样才能把它送回去?[安卓工作室],java,android,android-layout,navigation-drawer,materialcardview,Java,Android,Android Layout,Navigation Drawer,Materialcardview,我在我的activity\u main.xml中添加了一个MaterialCardView按钮com.google.android.material.card.MaterialCardView&导航抽屉com.google.android.material.navigation.NavigationView 如何在导航视图(@+id/navigation\u视图)后面发送MaterialCardView(@+id/cleanButton)? [这是完整的活动\u main.xml] <?
activity\u main.xml
中添加了一个MaterialCardView按钮com.google.android.material.card.MaterialCardView
&导航抽屉com.google.android.material.navigation.NavigationView
如何在导航视图(@+id/navigation\u视图)后面发送MaterialCardView(@+id/cleanButton)?
[这是完整的活动\u main.xml
]
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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"
android:id="@+id/main_layout"
tools:context="com.d4rk.cleaner.MainActivity">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/clean"
android:layout_width="90dp"
android:layout_height="64dp"
app:srcCompat="@drawable/ic_clean"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<ScrollView
android:id="@+id/fileScrollView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:focusable="false"
android:background="@drawable/card"
android:layout_marginEnd="24dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/cleanButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scanProgress">
<LinearLayout
android:id="@+id/fileListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:orientation="vertical"/>
</ScrollView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/cleanButton"
android:layout_width="152dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:onClick="clean"
app:cardCornerRadius="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scanProgress"
app:layout_constraintVertical_bias="0.045"
tools:ignore="UsingOnClickInXml">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_text_clean" />
</com.google.android.material.card.MaterialCardView>
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/scanProgress"
android:layout_width="150dp"
android:layout_height="144dp"
android:indeterminate="false"
android:progressDrawable="@drawable/circular"
app:layout_constraintBottom_toBottomOf="@+id/ScanTextView"
app:layout_constraintEnd_toEndOf="@+id/ScanTextView"
app:layout_constraintStart_toStartOf="@+id/ScanTextView"
app:layout_constraintTop_toTopOf="@+id/ScanTextView"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/ScanTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginBottom="32dp"
android:text="@string/main_progress"
android:textColor="@color/colorGoogleGreen"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="@+id/statusTextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/statusTextView"
app:layout_constraintVertical_bias="0.0" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/statusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_status"
android:textColor="@color/colorAccent"
android:textSize="36sp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.36"/>
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:minWidth="15dp">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="30dp"
android:layout_height="30dp"
android:autoLink="all"
android:clickable="true"
android:focusable="true"
android:text="@string/adfly"
android:textColor="#2E7D32"
android:textColorHighlight="@color/colorPrimary"
android:textColorHint="@color/colorPrimary"
android:textColorLink="@color/colorPrimary"
android:textIsSelectable="false"
app:drawableStartCompat="@drawable/ic_face"
tools:ignore="TextContrastCheck,TouchTargetSizeCheck" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="40dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:src="@drawable/ic_toolbar_d4rk"/>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:srcCompat="@drawable/ic_cleaner"/>
</androidx.appcompat.widget.Toolbar>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
app:srcCompat="@drawable/ic_line"
tools:ignore="MissingConstraints"/>
</LinearLayout>
</ScrollView>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header"
app:menu="@menu/drawer_menu">
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
根布局应该是
DrawerLayout
,您需要在DrawerLayout
中移动当前的ConstraintLayout
布局的框架应类似于:
<?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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Main screen layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Drawer layout -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header_layout"
app:menu="@menu/navigation_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
您可以在主屏幕上的
ConstraintLayout
中构建视图,将抽屉布局置于AppCompat.ImageViewNot working sir上方。当我添加时,物料卡片视图按钮就在后面(app:cardElevation=“0dp”)。但之后,该值按钮不起作用。谢谢,先生,部分工作。我做了这样的文件,按钮现在不在fornt上,但当我按下它时,它不工作XDDD,但我想说谢谢,因为这是一个进步XD@D4rK干得好这个问题可能是clean(View-View)
有一些问题,您可以在那里调试代码,如果发现问题,您可以打开一个新问题。。。如果您发现问题的答案是正确的,请点击左边的勾号接受答案。是的clen(View-View)
未使用。这在检验结果中有所体现。谢谢XD
<?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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Main screen layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Drawer layout -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header_layout"
app:menu="@menu/navigation_menu" />
</androidx.drawerlayout.widget.DrawerLayout>