- 浏览: 137920 次
- 性别:
文章分类
- 全部博客 (226)
- Android (181)
- C# (8)
- BOOTSTRAP (1)
- ASP.NET MVC4 (1)
- 设计模式 (1)
- VB.NET (1)
- WPF (0)
- PLC (0)
- 电气图纸 (0)
- 数据库 (5)
- Java (5)
- Window phone (0)
- 仪器仪表 (0)
- 变频器 (0)
- 低压电器 (0)
- 物联网 (0)
- Photoshop (1)
- SVN (1)
- 单片机 (5)
- IT (1)
- Android_IOS风格 (0)
- Android_广告栏展示 (0)
- Android_动画 (1)
- Android_Adapter (0)
- Android_ListView (1)
- Android_File (2)
- Android_表单提交 (0)
- Android_WebView (1)
- PHP (2)
- Android_Excel (1)
- Android_drawable (1)
- Android_theme (2)
- Android_phonegap (2)
- Android_AndroidManifest (1)
- ThinkPHP (0)
- Jquery (1)
- Android_ContentProvider (1)
最新评论
创建一个应用的主题
为了定义主题,打开 res/values/styles.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="MyAppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:typeface" >serif</item>
<item name="android:textColor">#000000</item>
<item name="android:textSize" >13pt</item>
<item name="android:shadowDx" >1.5</item>
<item name="android:shadowDy" >1.5</item>
<item name="android:shadowRadius" >1</item>
<item name="android:shadowColor" >#AAAAAA</item>
<item name="android:gravity" >center</item>
</style>
<style name="ButtonStyle">
<item name="android:layout_width" >300dp</item>
<item name="android:layout_height" >wrap_content</item>
<item name="android:layout_marginTop" >10dp</item>
<item name="android:textSize" >10pt</item>
<item name="android:background" >#FF0000</item>
</style>
</resources>
这里定义主题名是MyAppTheme 和<parent>根元素,这是从已有的主题中继承,也定义了样式名为ButtonStyle,包括一些属性,还定义了Button的主题,这里没有使用<parent>,因为是可选的。
下面是应用这个主题,这是通过 AndroidManifest.xml 完成,表示整个应用都是使用这个主题:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jdon.android.stylesthemestest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyAppTheme" >
<activity
android:name="com.jdon.android.stylesthemestest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
在application配置中,指定了样式为我们之前定义的MyAppTheme,为了设置样式,还要加上活动的配置。
创建活动布局
下面是创建一个活动的布局Layout,我们使用一个简单的布局,打开res/layout/activity_main.xml:
<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
android:id="@+id/customText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text 1..." />
<TextView
android:id="@+id/bigText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/customText"
android:text="Text 2..." />
<Button
android:id="@+id/simpleTextButton"
android:layout_below="@id/bigText"
style="@style/ButtonStyle"
android:text="SimpleStyle for Text 1" />
<Button
android:id="@+id/bigTextButton"
android:layout_below="@id/simpleTextButton"
style="@style/ButtonStyle"
android:text="BigPurpleStyle for Text 2" />
</RelativeLayout>
在这个布局中,我们也是有了我们定义的样式ButtonStyle。
下面编制主活动src/com.jdon.android.stylesthemestest/MainActivity.java
public class MainActivity extends Activity {
private Button simpleBtn, bigBtn;
private TextView text1, text2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text1 = (TextView) findViewById(R.id.customText);
text2 = (TextView) findViewById(R.id.bigText);
simpleBtn = (Button) findViewById(R.id.simpleTextButton);
simpleBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
text1.setTextAppearance(getApplicationContext(), R.style.SimpleStyle);
}
});
bigBtn = (Button) findViewById(R.id.bigTextButton);
bigBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
text2.setTextAppearance(getApplicationContext(), R.style.SimpleStyle_BigPurple);
}
});
}
}
http://www.oschina.net/question/234345_40092
为了定义主题,打开 res/values/styles.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="MyAppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:typeface" >serif</item>
<item name="android:textColor">#000000</item>
<item name="android:textSize" >13pt</item>
<item name="android:shadowDx" >1.5</item>
<item name="android:shadowDy" >1.5</item>
<item name="android:shadowRadius" >1</item>
<item name="android:shadowColor" >#AAAAAA</item>
<item name="android:gravity" >center</item>
</style>
<style name="ButtonStyle">
<item name="android:layout_width" >300dp</item>
<item name="android:layout_height" >wrap_content</item>
<item name="android:layout_marginTop" >10dp</item>
<item name="android:textSize" >10pt</item>
<item name="android:background" >#FF0000</item>
</style>
</resources>
这里定义主题名是MyAppTheme 和<parent>根元素,这是从已有的主题中继承,也定义了样式名为ButtonStyle,包括一些属性,还定义了Button的主题,这里没有使用<parent>,因为是可选的。
下面是应用这个主题,这是通过 AndroidManifest.xml 完成,表示整个应用都是使用这个主题:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jdon.android.stylesthemestest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyAppTheme" >
<activity
android:name="com.jdon.android.stylesthemestest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
在application配置中,指定了样式为我们之前定义的MyAppTheme,为了设置样式,还要加上活动的配置。
创建活动布局
下面是创建一个活动的布局Layout,我们使用一个简单的布局,打开res/layout/activity_main.xml:
<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
android:id="@+id/customText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text 1..." />
<TextView
android:id="@+id/bigText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/customText"
android:text="Text 2..." />
<Button
android:id="@+id/simpleTextButton"
android:layout_below="@id/bigText"
style="@style/ButtonStyle"
android:text="SimpleStyle for Text 1" />
<Button
android:id="@+id/bigTextButton"
android:layout_below="@id/simpleTextButton"
style="@style/ButtonStyle"
android:text="BigPurpleStyle for Text 2" />
</RelativeLayout>
在这个布局中,我们也是有了我们定义的样式ButtonStyle。
下面编制主活动src/com.jdon.android.stylesthemestest/MainActivity.java
public class MainActivity extends Activity {
private Button simpleBtn, bigBtn;
private TextView text1, text2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text1 = (TextView) findViewById(R.id.customText);
text2 = (TextView) findViewById(R.id.bigText);
simpleBtn = (Button) findViewById(R.id.simpleTextButton);
simpleBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
text1.setTextAppearance(getApplicationContext(), R.style.SimpleStyle);
}
});
bigBtn = (Button) findViewById(R.id.bigTextButton);
bigBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
text2.setTextAppearance(getApplicationContext(), R.style.SimpleStyle_BigPurple);
}
});
}
}
http://www.oschina.net/question/234345_40092
发表评论
-
LayoutInflater
2014-12-22 21:43 512在实际开发中LayoutInflater这个类还是非常有用的, ... -
ContentProvider之读写短消息
2014-12-08 11:08 565http://blog.csdn.net/liuhe ... -
android之启用默认浏览器
2014-11-03 12:36 480一、启动android默认浏览器 Intent inten ... -
eclipse下看android support v4源码
2014-09-18 22:24 600http://cfy10.blog.51cto.com/707 ... -
Android学习 (七)synchronized
2014-09-17 10:16 585http://hi.baidu.com/fenghuang12 ... -
ScheduledExecutorService定时周期执行指定的任务
2014-09-17 09:57 636http://blog.csdn.net/tsyj810883 ... -
android rotate
2014-09-16 15:21 1173rotate:fromDegrees:其实角度。toDegr ... -
Android获取Manifest中<meta-data>元素的值
2014-09-12 15:39 641在AndroidManifest.xml中,<meta- ... -
PopupWindow
2014-09-12 11:09 8481-初始化 PopupWindow mPop = new P ... -
Android的事件分发onInterceptTouchEvent与onTouchEvent、OnClickListener、OnLongClick
2014-09-11 11:05 869onInterceptTouchEvent()是ViewGro ... -
scrollTo、scrollBy、getScrollX、getScrollY这4个方法的含义,Scroller的简单用法
2014-09-11 10:43 1514scrollTo、scrollBy都是 对 ... -
VelocityTracker
2014-09-11 10:14 650android.view.VelocityTracker主要用 ... -
Android之SurfaceHolder
2014-09-09 16:05 568SurfaceHolder,可以把它当成surface的控制器 ... -
android performClick使用
2014-09-09 13:53 1111performClick 是使用代码主动去调用控件的点击事件( ... -
slidingmenu使用说明
2014-09-07 10:17 585左侧、右侧和两边 在BaseActivity中将Slid ... -
Android之SlidingMenu属性详解
2014-09-07 09:52 624SlidingMenu 常用属性介绍: menu.setMod ... -
Android IOS风格侧边栏效果
2014-08-27 13:45 319http://download.csdn.net/detail ... -
android 代码设置、打开wifi热点及热点的连接
2014-08-26 10:30 1007见博客文章 http://blog.csdn.net/luob ... -
Android 之两点触摸技术
2014-08-26 09:58 712package mobile.android.multi.to ... -
Android动画之translate(位移动画)
2014-08-25 15:53 445http://www.cnblogs.com/bavariam ...
相关推荐
Android开发中,界面友好能获得用户更多的青睐,本例子通过3种方法实现了换肤功能,欢迎参考!
Android Studio 护眼主题打包
Android Studio 一款很好用的主题,暗色背景,符合大多数人的审美。
androidstudio主题 intellij idea也可以用,自己设置的主题,导出。。使用的时候直接 import setting 就可以了。
将Android Studio的主题颜色设置为护眼模式的浅绿色。只需将该文件复制到Android Studio的:设置目录/config/colors下。然后在Android Studio中设置为改主题颜色即可
android桌面主题源代码,初学者或者自己想做DIV主题直接下载替换导出即可。
Android 主题换肤框架
android studio 好看的主题在这里!
此压缩包中包含7套场景桌面主题以及主题设计规范文档,完全适配本人上传的场景桌面代码,解压后,将scene目录放在手机SD卡根目录下即可,另外如果有需要,可自行设计主题,具体可以参考主题设计规范文档。
android 代码主题背景。里面有android studio代码主题背景,也有eclipse代码主题背景。也有设置方法,以及相关主题背景下载的网址。博客介绍:http://blog.csdn.net/qq_16064871/article/details/54645475。
android studio的 主题style,背景黑色,各种关键字和方法名,变量等颜色都有区分。使用方法,android studio -- File--Import setting... 选中该setting.jar--ok 重启studio
android自定义主题
个人非常喜欢的一个Android studio 主题包 类名、参数名、方法名等等都用各种颜色鲜明的区分开来了,一目了然
android设置多种主题风格,可实现背景,对话框,按钮风格的一键切换
Android 主题换肤-给要换肤的view打标签 给页面中需要的view设置标签来适配换肤 更新日志 效果图 支持 支持 textColor,textColorHint,background,src,drawableTop、drawableLeft、drawableRight、drawableBottom ...
ladies night2.jar ,cobalt.jar ,visual studio.jar, monokai sublime text3.jar
Android 主题换肤 插件化换肤 无缝切换
NULL 博文链接:https://wangleyiang.iteye.com/blog/1782695
Android studio 深色主题和快捷键修改
AndroidStudio将成为开发Android的主流,如此利器怎能没一款好看的主题样式,这是一款不错主题样式