简单练习自定义样式和主题,样式是加在View上,主题是加在Application或者Activity上

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 自定义样式 -->
<style name="MyFont">
<item name="android:textColor">#ff0000</item>
<item name="android:textSize">40sp</item>
</style>
<style name="MyFontSon" parent="@style/MyFont">
<item name="android:textSize">30sp</item>
</style>
<!-- 自定义主题 -->
<style name="MyTheme">
<item name='android:windowNoTitle'>true</item>
<item name="android:background">#ffffff</item>
</style>
</resources>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
style="@style/MyFont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="样式和主题"
/>
<TextView
style="@style/MyFontSon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="样式和主题"
/>
</LinearLayout>

Manifest.xml

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="ss"
android:theme="@style/MyTheme" >

[android] 安卓自定义样式和主题的更多相关文章

  1. Android RatingBar 自定义样式

    Android RatingBar 自定义样式 1.先定义Style: <style name="RadingStyle" parent="@android:sty ...

  2. xamarin android checkbox自定义样式

    xamarin android checkbox自定义样式 在drawable文件在新建checkbox_bg.xml文件 <?xml version="1.0" encod ...

  3. android中的样式和主题

    有的时候我们一个页面要用很多个textview,而且这些textview的样式非常相像,这种情况下我们可以把这些样式抽取出来,然后在每个textview中引用即可,这样修改起来也方便. 我们来看一个简 ...

  4. Android中自定义样式与View的构造函数中的第三个参数defStyle的意义

    零.序 一.自定义Style 二.在XML中为属性声明属性值 1. 在layout中定义属性 2. 设置Style 3. 通过Theme指定 三.在运行时获取属性值 1. View的第三个构造函数的第 ...

  5. Android下Notification,样式style,主题theme的功能实现

    一:Notification 1.NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVIC ...

  6. Android EditText自定义样式

    第一步:为了更好的比较,准备两个一模一样的EditText(当Activity启动时,焦点会在第一个EditText上,如果你不希望这样只需要写一个高度和宽带为0的EditText即可避免,这里就不这 ...

  7. android中的样式主题和国际化

    一.Android中的样式和主题     1.1样式     样式是作用在控件上的,它是一个包含一个或者多个view控件属性的集合.android style类似网页设计中的css设计思路,可以让设计 ...

  8. Android指南 - 样式和主题

    本文翻译自:https://developer.android.com/guide/topics/ui/themes.html Style和theme词汇是专用术语,下文直接使用而不翻译. 样式和主题 ...

  9. 安卓—自定义 AlertDialog 的样式

    自定义修改安卓弹出框的样式 效果图: 1.在style.xml下添加 <!-- 自定义弹出样式 --> <style name="MyDialogStyle" p ...

随机推荐

  1. 修改cmd默认启动路径

    1.打开注册表编辑器(WIN+R打开运行.输入regedit,或者直接找到路径,双击打开C:\Windows\regedit.exe): 2.定位到“HKEY_CURRENT_USER\Softwar ...

  2. 在macbookpro上开启ssh服务

  3. JVM_垃圾收集器

    最近刚好有时间,就简单的看了下JVM的几种垃圾回收器,它们都是计算机历史发展的产物,先简单的做一个整理,并没有哪一款垃圾收集器就一定是最优,还需要结合使用场景.参数配置等进行考量,根据系统情况搭配出尽 ...

  4. C# Winform下一个热插拔的MIS/MRP/ERP框架13(窗体基类)

    作为一个ERP数据处理框架,大部分的开发场景都差不多. 理想中,对于通用数据处理,我的步骤如下: 1.为窗体指定数据来源(数据表/查询等): 2.拖入编辑控件,指定绑定字段: 3.结束. 为此,我设计 ...

  5. ASP.NET Core中使用自定义验证属性控制访问权限

    在应用中,有时我们需要对访问的客户端进行有效性验证,只有提供有效凭证(AccessToken)的终端应用能访问我们的受控站点(如WebAPI站点),此时我们可以通过验证属性的方法来解决. 一.publ ...

  6. Python 验证码识别(别干坏事哦...)

    关于python验证码识别库,网上主要介绍的为pytesser及pytesseract,其实pytesser的安装有一点点麻烦,所以这里我不考虑,直接使用后一种库. python验证码识别库安装 要安 ...

  7. (php脚本自研分享)•通用型保存网站用户密码到css文件

    本文原创作者:Laimooc(原名xoanHn) 很多时候呢,我们拿到一个shell以后,偶尔会遇到密码解不了的情况,用xss收集cookie吧,感觉不方便:利用xss平台劫持表单吧,感觉麻烦,也会担 ...

  8. Android 中 DrawerLayout + ViewPager 怎么解决滑动冲突?

    DrawerLayout 是 Android 官方的侧滑菜单控件,而 ViewPager 相信大家都很熟悉了.今天这里就讲一下当在 DrawerLayout 中嵌套 ViewPager 时,要如何解决 ...

  9. iOS开发之像素Compositing

    假如Layer S·在Layer D上面,则最终的屏幕的颜色值如下: \[R = S + D \cdot (1- S_\alpha)\] \(R\): 最终的RGB \(S\): source col ...

  10. EOFError: Compressed file ended before the end-of-stream marker was reached

    EOFError: Compressed file ended before the end-of-stream marker was reached python在下载时,出现上述错误提示,一般这种 ...