[英]How to change my android application's theme?
我该如何更改应用程序的主题按钮和其他东西处于普通外观。我只想更改那些普通外观。
Use appcompat in your app, it gives some of the good things from lollipop to all pre-lollipop supported apps. 在您的应用程序中使用appcompat,它提供了从棒棒糖到所有棒棒糖之前支持的所有应用程序的一些好处。 http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html I have mimicked complete material design using appcompat. http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html我使用appcompat模仿了完整的材料设计。
Widgets supported by appcompat are: appcompat支持的小部件为:
For styling button use the below style: 对于样式按钮,请使用以下样式:
<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>
Also you can use this library to prep up your app with material design, https://github.com/navasmdc/MaterialDesignLibrary 您也可以使用此库通过材质设计为您的应用做准备, https://github.com/navasmdc/MaterialDesignLibrary
To change button style, you can change its background. 要更改按钮样式,可以更改其背景。 Here is an example for you. 这是给你的例子。 Follow these steps: 跟着这些步骤:
1. Define button background 1.定义按钮背景
For example: 例如:
<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. Create a new folder in res
folder 2.在res
文件夹中创建一个新文件夹
Right click on res folder in your project > New > Folder. 右键单击项目中的res文件夹>新建>文件夹。 Name it with drawable
. 用drawable
命名。
3. Create a new xml
file for your button background 3.为您的按钮背景创建一个新的xml
文件
Here, we can name it with button_background.xml
. 在这里,我们可以使用button_background.xml
对其进行button_background.xml
。 You may rename it later. 您可以稍后重命名。 Place it in drawable folder. 将其放在可绘制的文件夹中。 So, fill it with: 因此,请填写:
<?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>
And, completed... For information about changing app's theme, this is a reference for you: Styles and Themes 并且,完成...有关更改应用程序主题的信息,这是给您的参考: 样式和主题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.