位置: 编程技术 - 正文

android中style的学习心得(android style文件)

编辑:rootadmin

推荐整理分享android中style的学习心得(android style文件),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:android styleable,androidstudio的style没有,android style theme,android style theme,androidstudio的style没有,安卓style语法,安卓style语法,android styleable,内容如对您有帮助,希望把文章链接给更多的朋友!

通过学习发现android中界面、元素及动画一般都用到style,关于系统自带的styles.xml文件(我的在D:android-sdk-windowsplatformsandroid-dataresvaluesstyles.xml),源码如下:

<style name="WindowTitle"> <item name="android:singleLine">true</item> <item name="android:textAppearance">@style/TextAppearance.WindowTitle</item> <item name="android:shadowColor">#BB</item> <item name="android:shadowRadius">2.</item> </style> <style name="DialogWindowTitle"> <item name="android:maxLines">1</item> <item name="android:scrollHorizontally">true</item> <item name="android:textAppearance">@style/TextAppearance.DialogWindowTitle</item> </style>

……

以上是关于窗体或对话框样式;

<style name="Widget.ProgressBar.Horizontal"> <item name="android:indeterminateOnly">false</item> <item name="android:progressDrawable">@android:drawable/progress_horizontal</item> <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item> <item name="android:minHeight">dip</item> <item name="android:maxHeight">dip</item> <item name="android:mirrorForRtl">true</item> </style> <style name="Widget.SeekBar"> <item name="android:indeterminateOnly">false</item> <item name="android:progressDrawable">@android:drawable/progress_horizontal</item> <item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item> <item name="android:minHeight">dip</item> <item name="android:maxHeight">dip</item> <item name="android:thumb">@android:drawable/seek_thumb</item> <item name="android:thumbOffset">8dip</item> <item name="android:focusable">true</item> <item name="android:mirrorForRtl">true</item> </style>

……

以上是关于UI控件的样式;

<style name="Animation.Activity"> <item name="activityOpenEnterAnimation">@anim/activity_open_enter</item> <item name="activityOpenExitAnimation">@anim/activity_open_exit</item> <item name="activityCloseEnterAnimation">@anim/activity_close_enter</item> <item name="activityCloseExitAnimation">@anim/activity_close_exit</item> <item name="taskOpenEnterAnimation">@anim/task_open_enter</item>

……

</style>

……

以上是关于Activity切换时动画样式;

<style name="TextAppearance.Widget.ActionBar.Title" parent="@android:style/TextAppearance.Medium"> </style> <style name="TextAppearance.Widget.ActionBar.Subtitle" parent="@android:style/TextAppearance.Small"> </style>

android中style的学习心得(android style文件)

<style name="Widget.PopupMenu" parent="Widget.ListPopupWindow"> </style>

……

以上关于状态栏及弹出菜单样式,可以看出,样式也可以继承,parent对应父样式;

style.name是全局唯一的,其他地方要通过name关联引用的,parent有点类&#;继承。style标签里面的每一个<item />对应的是一个属性及其&#;,一般都是系统自带的属性,如果自定义style是可以包含自定义属性的。

在布局文件中,一般的UI控件若没有显示的设置style=""属性,系统在渲染时会默认给定一个,当然也可以显示指定控件的style属性,如下:

<ProgressBar android:layout_width="fill_parent" android:layout_height="wrap_content" style="@android:style/Widget.ProgressBar.Horizontal" />

<Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="button1" style="@android:style/Widget.Button.Inset" />

引用系统自带的style都是以“@android:style/”开头的&#;[style.name];其实可以看作style是包含很多属性的集合,它作为一个整体加到元素上的;

如果要自定义style也是可以的,在res/values/strings.xml文件里或在values目录下新建一个xxx.xml,写入自己的样式:

<style name="my_progress_style" parent="android:Widget.ProgressBar.Horizontal"> <item name="android:indeterminateOnly" >false</item> <item name="android:progressDrawable">@drawable/progress_layer_list</item> <item name="android:minHeight">5dp</item> <item name="android:maxHeight">5dp</item></style>

<style name="my_button_style" > <item name="android:background" >#ff</item> <item name="android:longClickable">false</item> <item name="android:alpha"></item> <item name="android:height">dp</item> <item name="android:width">dp</item></style>

上面第一个是定义了进度条样式它有继承父样式;第二个是定义了按钮样式,其实也可以用于其他控件,只要里面所有属性都支持;

在布局文件中引用自定义样式:

<ProgressBar android:layout_width="fill_parent" android:layout_height="wrap_content" style="@style/my_progress_style" />

去掉@android:直接使用@style/[style.name]。

大致了解这么多,细节还需再研究研究。

android 中添加字体:java.lang.RuntimeException: native typeface cannot be made 关于android自定义字体我想自行定义内容的字体,用了以下语句:TextViewtv=(TextView)findViewById(R.id.maintitle);//换字体Typefaceface=Typeface.createFromAsset(getAssets(),font

LRU缓存机制 今天在看Android内存优化的文档的时候,有一段提到了LRU内存缓存机制,当时一下没想起来,遂searchinnet.然后知道真相的我眼泪掉下来,%_%大学时候学的

android的focus问题 因为工作关系,涉及到很多的安卓物理键盘引起的Focus问题。汗,我估计在Androidcode这群人里,每天要和Focus问题打交道的少之又少了吧,现在好多应用

标签: android style文件

本文链接地址:https://www.jiuchutong.com/biancheng/376597.html 转载请保留说明!

上一篇:3行程序搞定SVM分类-用JAVA程序调用LibSVM API 最简单的示例

下一篇:android 中添加字体:java.lang.RuntimeException: native typeface cannot be made(android 字体设置)

  • 计提个税会计科目怎么做
  • 纳税人资格类型有哪些
  • 增值税未缴款能清卡吗
  • 未开票收入次月如何申报增值税
  • 小微企业做什么
  • 处置投资性房地产的损益怎么算
  • 医疗胶片扫描仪怎么用
  • 发票金额开多了怎么处理
  • 电信充值调账什么意思
  • 受托开发软件产品免征增值税
  • 服务行业印花税税率
  • 企业总资产是否包含累积折旧
  • 应付职工薪酬的一级科目
  • 企业分立房产税税收政策
  • 纳税人发生纳税义务,未按照规定
  • 单位经济合同由谁来签
  • 小规模商贸公司成本核算方法
  • 关于两套账老板和会计须知的4个点
  • 本年利润怎么算利润总额
  • 个税经营所得预扣预缴
  • 员工购买公司股权
  • 企业销售费用支出怎么算
  • 怎么关闭电量低
  • sixtypopsix.exe - sixtypopsix是什么进程 有什么用
  • php字符串函数有哪些
  • 施工企业自建自用的工程
  • jsPDF + html2canvas A4分页截断 完美解决方案(含代码 + 案例)
  • 前端 php
  • tensorflow1 教程
  • 跨境电商需要缴纳哪些税种
  • vue修改表格数据
  • 已经认证抵扣的发票怎么做账
  • 加工劳务费会计分录
  • 银行存款账面余额与银行账户余额
  • vue后端框架推荐
  • 邓弗里斯什么水平
  • websocket怎么用
  • nslookup命令大全
  • 加盟代理需要什么手续
  • 公司购买空调属于电子设备吗
  • 理财产品的分红和收益是分开的吗
  • python中sample函数怎么用
  • 案例详解:功能点估算法
  • 计提工资的时候跟发放的时候不一样怎么办
  • 企业代扣代缴个人所得税申报流程图
  • 零税率和免税的例子
  • sql20054n
  • 房地产企业政府返还款
  • 行政事业单位核销固定资产的账务处理
  • 样机 研发费用归集与核算
  • 补缴以前年度养老保险分录
  • 企业购买固定资产要交什么税
  • 加计抵减附加税怎么算
  • 制造费用就是制造成本吗
  • 预付账款的
  • 年度汇算清缴交税怎么做账
  • 企业净资产怎么填
  • mysql大小
  • mysql几天能学会
  • mac app store打开一片空白
  • linux mount -o remount
  • 安装win7系统后进不了系统
  • win7系统的虚拟内存在哪里
  • final cut pro能破解吗
  • linux快捷命令
  • windows8安装密钥永久
  • neoDVD.exe - neoDVD是什么进程 有什么用
  • win10系统访问不了
  • win7如何清理c盘空间不影响系统
  • win8wifi设置在哪
  • win7系统打不开设备与打印机
  • cocos安装
  • 开快打开
  • javascript日期加减
  • 用jquery
  • nodejs+ts
  • recyclerview瀑布流效果
  • 票据贴现的票据是什么
  • 长春市医保社保什么时候年检
  • 上海市网上税务局如何登录
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设