简体   繁体   中英

I am trying to create a login page in Android Studio but my button suddenly disappeared, it was working well before

这是截图,请看一下

Kindly help me resolve this problem. Everytime this happens and my button disappears:( The button is working fine, When I run the app the button even responds but I only see the outlines after running the app. The button color and the text disappeared to be exact. I am getting this problem everytime I try to create a new button.

Here is my xml file that is used to create the button

<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"
    tools:context=".Login">

   

        <ProgressBar
            android:id="@+id/progress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
           app:layout_constraintTop_toBottomOf="@+id/textInputLayoutPassword"/>

        <Button
            android:id="@+id/buttonLogin"
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30sp"
            android:text="@string/login"
            android:background="@color/colorAccent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/progress"
            android:visibility="visible"
            tools:targetApi="jelly_bean"/>

        <TextView
            android:id="@+id/signUpText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30sp"
            android:fontFamily="@font/poppinsmedium"
            android:text="@string/create_a_new_account_sign_up"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/buttonLogin"
            tools:targetApi="jelly_bean" />
    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

Can you please try to invalidate the android studio cache and restart your Android studio and see if that helps. As I was having the same issue and this flow Helped me fix it.

You can find the setting under File > Invalidate Caches / Restart

Thank you for the responses guys, it was happenening because of the theme,

<activity
    android:theme="@android:style/Theme.NoTitleBar"
</activity>

Adding this line of code in the AndroidManifest.xml file solved the problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM