Android自定義Style實(shí)現(xiàn)方法
styles.xml如下:
[html]
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="testStyle">
<item name="android:textSize">30px</item>
<item name="android:textColor">#1110CC</item>
<item name="android:width">150dip</item>
<item name="android:height">150dip</item>
</style>
</resources>
main.xml如下:
[html]
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
style="@style/testStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
MainActivity如下:
[java]
package com.cn;
import android.os.Bundle;
import android.app.Activity;
/**
* Demo示例:
* 為控件設(shè)置自定義的Style
* 步驟:
* 1 在styles.xml文件中自定義一個(gè)style
* 在該style中可以預(yù)設(shè)各種參數(shù).如文字大小,顏色
* 寬,高等等屬性
* 2 在布局文件中為控件設(shè)置style屬性,如:style="@style/testStyle"
*/
public class MainActivity extends Activity {
@Override www.dhdzp.com
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
- Android設(shè)置Activity背景為透明style的簡(jiǎn)單方法(必看)
- Android Style.xml的應(yīng)用詳解及代碼實(shí)現(xiàn)
- Android開發(fā) -- UI界面之threme和style
- Android中自定義控件的declare-styleable屬性重用方案
- Android入門之Style與Theme用法實(shí)例解析
- Android 避免APP啟動(dòng)閃黑屏的解決辦法(Theme和Style)
- 基于android樣式與主題(style&theme)的詳解
- Android style的繼承方式 點(diǎn)(.)和parent詳解及實(shí)例
相關(guān)文章
Android startActivityForResult()代替方案示例
這篇文章主要為大家介紹了Android startActivityForResult()代替方案示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08
Android使用popupWindow仿微信彈出框使用方法
這篇文章主要為大家詳細(xì)介紹了Android使用popupWindow仿微信彈出框使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-09-09
Android studio 快速刪除無(wú)用資源的方法
最近苦于android 項(xiàng)目越來(lái)越大,項(xiàng)目需求不停變動(dòng)。項(xiàng)目中的資源文件越來(lái)越雜,越來(lái)越亂。android studio怎么刪除無(wú)用資源呢?下文圖文并茂給大家介紹的非常詳細(xì),需要的朋友參考下吧2017-11-11
Android實(shí)現(xiàn)可拖動(dòng)層疊卡片布局
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)可拖動(dòng)層疊卡片布局,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11
Android中實(shí)現(xiàn)毛玻璃效果的3種方法
這篇文章主要介紹了Android中實(shí)現(xiàn)毛玻璃效果的3種方法,本文講解了使用系統(tǒng)提供的方法、自定義的方法、C語(yǔ)言實(shí)現(xiàn)方法等3種方法,需要的朋友可以參考下2015-04-04
在Android環(huán)境下WebView中攔截所有請(qǐng)求并替換URL示例詳解
這篇文章主要介紹了在Android環(huán)境下WebView中攔截所有請(qǐng)求并替換URL示例詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07
詳解Android中fragment和viewpager的那點(diǎn)事兒
本文主要對(duì)Android中fragment和viewpager進(jìn)行詳細(xì)介紹,具有一定的參考價(jià)值,需要的朋友一起來(lái)看下吧2016-12-12
Android ImageView 不顯示JPEG圖片的問(wèn)題解決
本篇文章主要介紹了Android ImageView 不顯示JPEG圖片及Android Studio中如何引用圖片資源的相關(guān)知識(shí),具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧2017-05-05
基于Android實(shí)現(xiàn)仿QQ5.0側(cè)滑
本課程將帶領(lǐng)大家通過(guò)自定義控件實(shí)現(xiàn)QQ5.0側(cè)滑菜單,課程將循序漸進(jìn),首先實(shí)現(xiàn)最普通的側(cè)滑菜單,然后引入屬性動(dòng)畫與拖動(dòng)菜單效果相結(jié)合,最終實(shí)現(xiàn)QQ5.0側(cè)滑菜單效果。通過(guò)本課程大家會(huì)對(duì)側(cè)滑菜單有更深層次的了解,通過(guò)自定義控件和屬性動(dòng)畫打造千變?nèi)f化的側(cè)滑菜單效果2015-12-12

