使用了Theme但是没有效果问题
最近在开发过程中使用了theme移植Preference并使用了一些android样式,但是在自定义的Theme修改了相关参数后却无法实现
可能有些朋友还不知道怎么用。这里也做个简要的使用方式说明。
1. xml中使用样式。
android:textAppearance="?android:attr/textAppearanceLarge"
?android:使用安卓内置样式。
<TextView android:id="@id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true" android:text="Hellopss"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceLarge"
android:fadingEdge="horizontal" />
2.View中使用到xml
setContentView(xml)
3. 定义Theme
<style name="AppTheme" parent="@style/AppThemsse">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<!-- Text styles -->
<item name="android:textAppearance">@style/TextAppearance</item>
<item name="android:textAppearanceInverse">@style/TextAppearance.Inverse</item>
<item name="android:textAppearanceLarge">@style/TextAppearance.Large</item>
<item name="android:textAppearanceMedium">@style/TextAppearance.Medium</item>
<item name="android:textAppearanceSmall">@style/TextAppearance.Small</item>
<item name="android:textAppearanceLargeInverse">@style/TextAppearance.Large.Inverse</item>
<item name="android:textAppearanceMediumInverse">@style/TextAppearance.Medium.Inverse</item>
<item name="android:textAppearanceSmallInverse">@style/TextAppearance.Small.Inverse</item>
<item name="android:textAppearanceButton">@style/TextAppearance.Widget.Button</item>
<item name="android:textColorPrimary">#000079</item>
<item name="android:textColorSecondary">#000079</item>
<item name="android:textColorTertiary">@color/tertiary_text_light</item>
<item name="android:textColorPrimaryInverse">@color/primary_text_dark</item>
<item name="android:textColorSecondaryInverse">@color/secondary_text_dark</item>
<item name="android:textColorTertiaryInverse">@color/tertiary_text_dark</item>
<item name="android:textColorPrimaryDisableOnly">@color/primary_text_light_disable_only</item>
<item name="android:textColorPrimaryInverseDisableOnly">@color/primary_text_dark_disable_only</item>
<item name="android:textColorPrimaryNoDisable">@color/primary_text_light_nodisable</item>
<item name="android:textColorSecondaryNoDisable">@color/secondary_text_dark_nodisable</item>
<item name="android:textColorPrimaryInverseNoDisable">@color/primary_text_dark_nodisable</item>
<item name="android:textColorSecondaryInverseNoDisable">@color/secondary_text_dark_nodisable</item>
<item name="android:textColorHint">@color/hint_foreground_light</item>
<item name="android:textColorHintInverse">@color/hint_foreground_dark</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:textColorHighlight">#FFFF9200</item>
<item name="android:textColorHint">?android:textColorHint</item>
<item name="android:textColorLink">#5C5CFF</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
</style>
theme修改该引用的样式
4. Theme使用
AndroidManifest.xml 中设置该Theme android:theme="**"
5. 使用View
(1)直接xml导入View
(2)先new View(这样出现了所描述的问题)
PreferenceScreen mPreferenceScreen = getPreferenceManager().createPreferenceScreen(getApplicationContext());
Preference mPreference = new Preference(this);
mPreference.setTitle("我的应用世界");
mPreference.setSummary("测试自定义Preference");
mPreference.setKey("hello");
mPreferenceScreen.addPreference(mPreference);
注意红色的地方,如果使用的是getApplicationContent()不知不觉中就出现无法使用theme了。
惠存!
使用了Theme但是没有效果问题的更多相关文章
- Material Designer的低版本兼容实现(二)—— Theme
Theme material主题可以定义为如下形式: @android:style/Theme.Material @android:style/Theme.Material.Light @androi ...
- android学习笔记50——SQLiteOpenHelper、android实现系统自带样式
SQLiteOpenHelper SQLiteOpenHelper是android提供的一个管理数据库的工具类,可用于管理数据库的创建和版本更新. 一般的用法是创建SQLiteOpenHelper的子 ...
- Android学习笔记--AlertDialog应用
1. 自定义实现带图标的TextView IconTextView.java package com.evor.andtest; import android.content.Context; imp ...
- VSCode瞎折腾记
搬到小机房后终于能用VSCode啦(没错以前的系统是xp) 但是这东西比Dev难搞多了qwq,简单记一下自己的DIY历程吧(不然全搞炸就凉了) 设置语言为中文 可以直接下载插件 让VSCode支持编译 ...
- Android中样式及主题
Android应用程序中不可避免的需要使用的样式和主题,样式指定一般指定View的高度.字体.字体颜色.背景,Android里的样荐定义在Style.xml文件里.主题也是一种样式,只不过它是应用在整 ...
- C++Windows核心编程读书笔记
转自:http://www.makaidong.com/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E6%96%87/71405.shtml "C++Windows核心编程读书笔 ...
- 【转】《windows核心编程》读书笔记
这篇笔记是我在读<Windows核心编程>第5版时做的记录和总结(部分章节是第4版的书),没有摘抄原句,包含了很多我个人的思考和对实现的推断,因此不少条款和Windows实际机制可能有出入 ...
- Activity + 基础UI
目录 Activity + 基础UI 1. 返回键退出进入应用: 2. home键以后 3. home键退出切换字体 二:AndroidManifest配置theme改变UI效果 三:UI 报错: A ...
- IDEA界面太丑??尝试一下这几个风格
>>>>>>>>>>原文地址<<<<<<<<<< >>>> ...
随机推荐
- js获取上一页、当前页及域名url方法,JS反回上一页的方法
<html> <head> <title>js获取上一页url,js获取前一页地址,javascripts获取上一页url,javascript获取前一页地址< ...
- 前端开发 Grunt 之 Connect
在前端开发过程中,我们需要在开发过程中,将开发中的站点部署到服务器上,然后,在浏览器中查看实际的效果,在 Grunt 环境下,可以直接使用集成在 Grunt 中的 Connect 插件完成站点服务器的 ...
- Android 媒体键监听以及模拟媒体键盘的实现 demo
有时我们需要程序模拟按钮或点击,而手机本身又没有,哪么可以采取其它方式 模拟实现,最后再去实际设备去测试(前期一般都拿不到设备): 如上一首,下一首,暂停等,手机上是没有的,但有些设备上是有的,所以我 ...
- jmeter的分布式部署
在使用Jmeter进行性能测试时,如果并发数比较大(比如5000+并发),单台电脑的配置(CPU和内存)可能无法支持(公司配的联想e450家庭用笔记本一般到1000就会卡死),这时可以使用Jmeter ...
- DragonBone在FlashDevelop编译
http://dragonbones.github.io/ dragonbones是一个强大的骨骼动画编辑器,基于Starling,用AS3语言编写,可以导出骨骼动画数据供其他程序使用. 下面来讲一下 ...
- 慕课网-安卓工程师初养成-3-3 Java中的赋值运算符
来源:http://www.imooc.com/code/1298 赋值运算符是指为变量或常量指定数值的符号.如可以使用 “=” 将右边的表达式结果赋给左边的操作数. Java 支持的常用赋值运算符, ...
- MapReduce和Tez对比
MapReduce是一种编程模型,用于大规模数据集(大于1TB)的并行运算.概念"Map(映射)"和"Reduce(归约)". Tez是Apache开源的支持D ...
- C++ Namespace 详解
命名空间的定义格式为:(取自C++标准文档) named-namespace-definition: namespace identifier { namespace-body } unnamed-n ...
- PAT1053. Path of Equal Weight
//之前一直尝试用vector存储path,但是每次错误后回退上一级节点时不能争取回退,导致探索路径正确,但是输出不正确,用参数num,标记前一个路径点的位置传递参数,就好多了 //其中在输入时就将后 ...
- Centos更新yum packet源
在使用Centos时,常常会遇到使用yum安装某些系统依赖包,特别是第三方软件库(如openstack软件库)时,无法找到包源.因此,需要将Centos的yum源进行更新,扩展,以便可以通过yum的方 ...