`
liangoogle
  • 浏览: 273302 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

android 中theme.xml与style.xml的区别

 
阅读更多

android 中theme.xml与style.xml的区别:

相同点:

两者的定义相同。

  1. <resources>
  2. <stylename="theme"parent="android:Theme.Black">
  3. <itemname="android:windowNoTitle">true< /item>
  4. <itemname="android:textSize">14sp< /item>
  5. <itemname="android:textColor">#FFFF0000< /item>
  6. < /style>
  7. < /resources>

不同点:

一、使用的地方不同

        1.theme.xml:对整个应用或某个Activity存在全局性影响。

 

                    AndroidManifest.xml中:

                    <application android:theme="@android:style/theme">,

                    <activity android:theme="@android:style/theme">,

 

                   application 和  activity  java中:setTheme(R.style.theme);  

         2 style.xml:用在单独的View。

 

                 <EditText android:layout_height="wrap_content"

                   android:text="EditText"

                   style="@style/Title"

                   android:layout_width="fill_parent"

                   android:id="@+id/editText1"></EditText>

二、 在R.attr定义中以window开头的一些属性只对theme有效。

三、如果一个应用使用了theme,同时应用下的view也使用了style,那么当theme与样式style发生冲突时,style的优先级高于主题。

分享到:
评论

相关推荐

    Android Style.xml的应用详解及代码实现

    主要介绍了Android Style.xml的应用详解及代码实现的相关资料,需要的朋友可以参考下

    Android Style\\Theme动态切换

    NULL 博文链接:https://trinityblood.iteye.com/blog/1743655

    Android入门之Style与Theme用法实例解析

    就目前的互联网发展来看,已经有越来越多...Android系统的themes.xml和style.xml(位于/base/core/res/res/values/)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。以下的这段代码属性是在Th

    Android Studio如何去除界面默认标题栏

    (2)找到其中为 android:theme=”@style/AppTheme” 的语句,如图: (3)将其修改为 android:theme=”@style/Theme.AppCompat.NoActionBar” 即可。 至若春和景明,波澜不惊,上下天光,一碧万顷;沙鸥翔集,锦鳞...

    Android移动开发实验6.doc

    &lt;com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"&gt; &lt;androidx.appcompat.widget....

    Android状态保存、用户偏好设置保存、通过universal_image_loder网络加载图片并做图片缓存处理Demo

    android:theme="@style/AppTheme" &gt; android:name="com.example.save.CopyOfMainActivity" android:label="@string/app_name" &gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android...

    Android程序技术:样式、主题、国际化.pptx

    主题(theme)应用到整个Activity和Application的样式,当设置好主题后,Activity或整个程序中的视图都将使用主题中的属性,当主题和样式中的属性发生冲突时,样式的优先级要高于主题。 自定义主题代码如下(styles....

    Android开发 — UI界面之threme和style

    Android系统的themes.xml和style.xml(位于\base\core\res\res\values\)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。 一、threme android中的主题一般用于窗体级别的,用于改变窗体样式 1、...

    MyFileChooser.rar

    android:theme="@android:style/Theme.NoTitleBar" 或在主题中按下面方式添加 &lt;style name="myChooserStyle" parent="@style/AppTheme"&gt; &lt;item name="android:windowBackground"&gt;@android:color/...

    Android中Theme主题和Style样式使用介绍总结

    在AS中res/values/style.xml中定义,例如新建项目AS自动创建的Theme,是系统提供; @color/colorPrimary @color/colorPrimaryDark @color/colorAccent Android系统提供的主题在:..\platforms\android-29\

    BaiduMap_AndroidSDK Sample_demo

    android:theme="@style/AppTheme"&gt; &lt;!--这里添加正确的key和value --&gt; &lt;meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="7OkUCRXhEG379MBvwHNG4qmbY1QTnI19" /&gt; .................

    Android模拟器全屏问题

    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 其次 ,必须注意你的模拟器的分辨率和density 例如 ,我的模拟器的尺寸为HVGA,即分辨率为320*480,density为160. 所以在导入图片时应该注意: ...

    Android代码-MultipleTheme

    真正的支持无缝换肤/夜间模式的Android框架,配合theme和换肤控件框架可以做到无缝切换换肤(无需重启应用和当前页面)。 该应用框架可以实现无缝换肤/切换夜间模式的需求,需要在换肤/切换夜间模式的界面只需要...

    安卓代码日志分析

    -&lt;application android:theme="@style/AppTheme" android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:allowBackup="true"&gt; -&lt;activity android:name=...

    Android中自定义对话框(Dialog)的实例代码

    1.修改系统默认的Dialog样式...在源码中的路径:/frameworks/base/core/res/res/values/themes.xml,我们可以看到,Android为Dialog定义了一个样式, 代码如下:&lt;style name=”Theme.Dialog”&gt;&lt;item name=”a

    Android自定义Style实现方法

    style name=”AppBaseTheme” parent=”android:Theme.Light”&gt; &lt;/style&gt; &lt;style name=”AppTheme” parent=”AppBaseTheme”&gt; &lt;/style&gt; &lt;style name=”testStyle”&gt; &lt;item name...

    透明与窗体的设置

    PS1:如果只是将Acticity显示为默认的Dialog, 跳过第一步,只需要在manifest文中增加属性:android:theme="@android:style/Theme.Dialog"或者在程序中增加setTheme(android.R.style.Theme_Dialog). PS2:其他创建...

    Android中去掉标题栏的几种方法(三种)

    2.在manifest.xml中改Theme 3.先在style.xml中自定义style &lt;?xml version=1.0 encoding=UTF-8 ?&gt; &lt;style name=notitle&gt; &lt;item name=android:windowNoTitle&gt;true &lt;/style&gt; 再在manifest.xml中...

    ContentProvider

    android:theme="@style/AppTheme" &gt; android:name="com.example.tigongzhe.MainActivity" android:label="@string/app_name" &gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category ...

    debugoverlay-在页面上方以半透明层的方式弹出消息、通知.zip

     android:theme="@style/AppTheme" &gt;   android:name="com.hannesdorfmann.debugoverlay.DebugOverlayService"/&gt;  &lt;/application&gt;2. 直接弹出消息DebugOverlay.with(MainActivity.this).log("消息1 "); //...

Global site tag (gtag.js) - Google Analytics