Images of files to which I made changes after creating the project
Code from my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center"
android:orientation="vertical"
android:background="@drawable/ic_bg"
tools:context=".MainActivity">
<TextView
android:id="@+id/tv_app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:textStyle="bold"
android:textColor="@color/white"
android:textSize="25sp"
android:gravity="center"
android:text="QuizBuzz"/>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="8dp"
app:cardElevation="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#363A43"
android:textSize="16sp"
android:text="Welcome"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#7A8089"
android:textSize="18sp"
android:text="Please enter your name"
/>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<androidx.appcompat.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#363A43"
android:textColorHint="#7A8089"
android:hint="Name"/>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@color/purple_500"
android:text="Start">
</Button>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
Problem
When I am clicking the run button, I m getting an error (Image of error -from the 1st list)
I am new to android development. So I cannot understand what is exactly happening. Please help me pinpoint the problem.
if you need anything more please let me know. if you can help me with some online resources I will be grateful.
2
Answers
Try this:
Add these missing colors to your colors.xml file:
If you’re using Jetpack Compose, then just remove the old themes files and add a single one that needs this content:
And to set the theme also in AndroidManifest file.