如何更改我的app的主题。按钮和其他东西都是普通的外观。我只是想改变那些普通的外观。
答案 0 :(得分:0)
在你的应用程序中使用appcompat,它提供了从棒棒糖到所有棒棒糖前支持的应用程序的一些好东西。 http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html 我使用appcompat模仿完整的材料设计。
appcompat支持的小部件是:
对于样式按钮,请使用以下样式:
<style name="Button">
<item name="android:textColor">@color/white</item>
<item name="android:padding">0dp</item>
<item name="android:minWidth">88dp</item>
<item name="android:minHeight">36dp</item>
<item name="android:layout_margin">3dp</item>
<item name="android:elevation">1dp</item>
<item name="android:translationZ">1dp</item>
<item name="android:background">@drawable/primary_round</item>
</style>
此外,您可以使用此库为材料设计https://github.com/navasmdc/MaterialDesignLibrary
准备应用程序答案 1 :(得分:0)
要更改按钮样式,您可以更改其背景。这是一个例子。请按照以下步骤操作:
<强> 1。定义按钮背景
例如:
<Button
android:id="@+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:background="@drawable/button_background" // this is your button background
android:text="@string/myButton"
android:textColor="@color/white"/>
<强> 2。在res
文件夹
右键点击项目中的res文件夹&gt; 新&gt; 文件夹。使用drawable
命名。
第3。为您的按钮背景创建一个新的xml
文件
在这里,我们可以使用button_background.xml
命名。您可以稍后重命名。将它放在可绘制的文件夹中。所以,请填写:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- view background color-->
<solid android:color="@color/your_background_color" >
</solid>
<!-- If you want to add some padding -->
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" />
<!-- Here is the corner radius -->
<corners
android:radius="6dp" >
</corners>
</shape>
并且,已完成...有关更改应用主题的信息,请参考以下内容:Styles and Themes