Android学习-第53天
今天的任务为改变主题、添加主题颜色以及覆盖主题属性、修改按钮属性,代码如下:
styles.xml:
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/red</item> <item name="colorPrimaryDark">@color/dark_red</item> <item name="colorAccent">@color/gray</item> <item name="android:windowBackground">@color/soothing_blue</item> <item name="buttonStyle">@style/BeatBoxButton</item> </style> <style name="BeatBoxButton"> <item name="android:background">@color/dark_blue</item> </style> </resources>
list_item_sound.xml:
<?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <data> <variable name="viewModel" type="com.bignerdranch.android.beatbox.SoundViewModel"/> </data> <Button android:layout_width="match_parent" android:layout_height="120dp" android:onClick="@{() -> viewModel.onButtonClicked()}" android:text="@{viewModel.title}" tools:text="Sound name"/> </layout>
截图如下: