[英]How to change my android application's theme?
我該如何更改應用程序的主題按鈕和其他東西處於普通外觀。我只想更改那些普通外觀。
在您的應用程序中使用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.定義按鈕背景
例如:
<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文件夾>新建>文件夾。 用drawable
命名。
3.為您的按鈕背景創建一個新的xml
文件
在這里,我們可以使用button_background.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>
並且,完成...有關更改應用程序主題的信息,這是給您的參考: 樣式和主題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.