Android/Android Tip
[Android/안드로이드] android material Design 사용하기
olivia
2020. 4. 24. 15:47
안드로이드에서 머티리얼 디자인 사용하기를 시작해보겠습니다.
1. build.gradle(:project)
- repositories 섹션에 google() 추가
allprojects {
repositories {
...
google()
...
}
}
2. build.gradle(:app)
- dependencies 섹션에 라이브러리 추가
(최신 버전 확인 Google Maven Repository 확인)
dependencies {
...
//material
implementation "com.google.android.material:material:$material_version"
}
3. AppCompatActivity 를 사용
4. app 테마에서 Material Components theme을 상속받도록 한다.
- AndroidManifest.xml
<application
...
android:theme="@style/AppTheme">
</applicaion>
- style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Material Components themes
- Theme.MaterialComponents
- Theme.MaterialComponents.NoActionBar
- Theme.MaterialComponents.Light
- Theme.MaterialComponents.Light.NoActionBar
- Theme.MaterialComponents.Light.DarkActionBar
- Theme.MaterialComponents.DayNight
- Theme.MaterialComponents.DayNight.NoActionBar
- Theme.MaterialComponents.DayNight.DarkActionBar
5. 사용하고 싶은 material component 를 추가한다
- 컴포넌트 종류
끝!!