为什么,在删除Android studio中的按钮后’;s的布局,它还能看到吗?

为什么,在删除Android studio中的按钮后’;s的布局,它还能看到吗?,android,android-studio,android-layout,android-button,Android,Android Studio,Android Layout,Android Button,我从布局中删除了注册按钮,android studio没有看到它,但当应用程序启动时,它出现了 <?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/ap

我从布局中删除了注册按钮,android studio没有看到它,但当应用程序启动时,它出现了

<?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:backgroundTint="@color/colorPrimaryDark"
    android:layout_height="match_parent"
    tools:context=".home.MainActivity">

    <FrameLayout
        android:id="@+id/nav_host_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toTopOf="@id/roundLayout"/>

    <com.github.florent37.shapeofview.shapes.RoundRectView
        android:id="@+id/roundLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:elevation="12dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:shape_roundRect_bottomLeftRadius="22dp"
        app:shape_roundRect_bottomRightRadius="22dp"
        app:shape_roundRect_topLeftRadius="8dp"
        app:shape_roundRect_topRightRadius="8dp">

        <com.ismaeldivita.chipnavigation.ChipNavigationBar
            android:id="@+id/chipNavigationMenu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="@color/white"
            app:cnb_menuResource="@menu/bottom_menu"/>

    </com.github.florent37.shapeofview.shapes.RoundRectView>

</androidx.constraintlayout.widget.ConstraintLayout>
[]

[]

[]最快的解决方案 尝试使用Android Studio上的运行或调试图标在模拟器上重新启动应用程序

清洁剂溶液
  • 从emulator中删除应用程序
  • 删除在
    app/build/outputs/apk/debug/app debug.apk
  • 通常在以下任一情况下都会发生此问题

  • 不重新运行应用程序时,仅更改布局
  • 使用Instant run时,有时可能不会立即重新渲染,这需要几秒钟的时间

  • 你使用即时跑步吗?如果您没有禁用它-这可能是导致此问题的原因。@VladyslavMatviienko我没有此设置尝试使缓存无效,然后重新启动并从android studio emulator中删除apk文件…它应该可以工作,可能您有多个布局文件,这不是您在活动中使用的按钮。禁用即时运行,然后应用无效缓存并重新启动。如果没有帮助,此按钮仍然出现。您是否正在检查从中删除按钮的同一视图,现在我添加了另一个按钮,但他没有看到它问题中给出的文件名是什么?activity_home.xml
    import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import android.os.PersistableBundle
    import androidx.fragment.app.Fragment
    import cheprasov.egor.cchat.R
    import cheprasov.egor.cchat.fragments.favorite.favorites
    import cheprasov.egor.cchat.fragments.home.homeFragment
    import cheprasov.egor.cchat.fragments.settings.settings
    import com.google.firebase.auth.FirebaseAuth
    import com.ismaeldivita.chipnavigation.ChipNavigationBar
    
    class MainActivity : AppCompatActivity() {
    
        private lateinit var auth: FirebaseAuth
        private lateinit var mAthListner: FirebaseAuth.AuthStateListener
        private lateinit var menu: ChipNavigationBar
        private var fragment: Fragment? = null
        private lateinit var fragmentsHome: Fragment
        private lateinit var fragments: Fragment
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.main_activity)
            init()
    
            if(fragment== null){
                val transaction = supportFragmentManager.beginTransaction()
                fragmentsHome = homeFragment()
                transaction.replace(R.id.nav_host_fragment,fragmentsHome)
                transaction.commit()
            }
            menu.setOnItemSelectedListener { id ->
                val option = when (id){
                    R.id.home -> {
                        fragments = fragmentsHome
                        setFragment(fragments)
                    }
                    R.id.favorited -> {
                        fragments = favorites()
                        setFragment(fragments)
                    }
                    R.id.settings ->{
                        fragments = settings()
                        setFragment(fragments)
                    }
                    else -> finish()
                }
            }
        }
    
        private fun setFragment(fragment: Fragment){
            val transaction = supportFragmentManager.beginTransaction()
            transaction.replace(R.id.nav_host_fragment,fragment)
            transaction.commit()
        }
    
    
        private fun init(){
            auth = FirebaseAuth.getInstance()
            menu = findViewById(R.id.chipNavigationMenu)
        }
    
        override fun onStop() {
            super.onStop()
        }
    
        override fun onPause() {
            super.onPause()
        }
    
        override fun onRestoreInstanceState(savedInstanceState: Bundle) {
            super.onRestoreInstanceState(savedInstanceState)
        }
    
        override fun onResume() {
            super.onResume()
        }
    
        override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
            super.onSaveInstanceState(outState, outPersistentState)
        }
    
        override fun onBackPressed() {
            super.onBackPressed()
            moveTaskToBack(true)
        }
    
        private fun signOut(){
            auth.signOut()
        }
    }