skip to Main Content

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


  1. Try this:

    Add these missing colors to your colors.xml file:

       <item name="colorPrimaryVariant">@color/purple_700</item>
       <item name="colorOnPrimary">@color/black</item>
      <item name="colorSecondaryVariant">@color/teal_200</item>
      <item name="colorOnSecondary">@color/black</item>
    
    Login or Signup to reply.
  2. If you’re using Jetpack Compose, then just remove the old themes files and add a single one that needs this content:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <style name="Theme.YourProject" parent="android:Theme.Material.Light.NoActionBar">
            <item name="android:statusBarColor">@color/purple_700</item>
        </style>
    </resources>
    

    And to set the theme also in AndroidManifest file.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search