What to do immediately after introducing Material Design

Overview

I will write what to do after introducing Material Design to the Android project. This is done for Hello world after creating an Android project.

Library introduction

In order to introduce Material Design, write build.gradle as follows.

build.gradle


    // material design
    api 'com.google.android.material:material:1.2.0-alpha06'

Changes to styles.xml

Write res / values / styles.xml as follows.

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

Changes to activity_main.xml

Change res / layout / activity_main.xml and check the display.

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

    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Verification"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        />

</androidx.constraintlayout.widget.ConstraintLayout>

result

Confirm that the following display is displayed

Digression

If you leave res / values / styles.xml in the default state, the following error will be displayed.

Error inflating class com.google.android.material.button.MaterialButton

reference

Recommended Posts

What to do immediately after introducing Material Design
What to do after Vagrant install
What to do after updating Dockerfile, docker-compose.yml
[Rails 6] What to do when a missing a template error occurs after introducing haml [Super easy]
What to do when javax.batch.operations.JobStartException occurs
What to do if changes are not reflected after automatic deployment to EC2
What to do if the background image is not applied after deployment
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
What to do when a javax.el.PropertyNotWritableException occurs
What to do if you install Ubuntu
What to do when undefined method ʻuser_signed_in?'
What to do if the server tomcat dies
What to do if you push incorrect information
What to do if mvn archetype: generate fails
What to do when debugging "Source not found"
What do you use when converting to String?
What to do when IllegalStateException occurs in PlayFramework
What to do if the update does not take effect after deploying Rails AWS
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
What to do when Address already in use is displayed after executing rails s
What to do when routing settings do not work after building Docker environment with Laravel
What to do if you can't find your API key after deploying to Rails heroku
What to do if the debug gem installation fails
What to do if the Rails server can't start
What to do when The SSL certificate has expired
What to do when JSF tags do not become HTML
What to do if ClassNotFoundException occurs when starting Tomcat
What to do if rails server can't be stopped
What to do if TextToSpeech doesn't work on Android 11
What should I do to reload the updated Dockerfile?
What to do if you accidentally create a model
What Is Domain Driven Design Trying to Solve [DDD]
What to do when a null byte error occurs
What to do when rails creates a 〇〇 2.rb file
What to do if an ActionController :: UnknownFormat error occurs
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
What to do if password authentication fails in Docker/Postgres
ParseException: What to do when Unparseable date is reached
[Java] [Spring] What to do if you cannot Autowire with Type Mismatch after annotating Spring Security