位置: 编程技术 - 正文

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 字体设置)

  • 不得公开发行股票的情形
  • 一次性扣除固定资产政策案例
  • 电梯维保费属于建筑服务吗
  • 企业所得税季度申报填写示例
  • 房产税当月计提额怎么算
  • 建筑行业未收款先开发票如何做账?
  • 吸收合并控股合并新设合并的区别
  • 工资分开发的奖金具体个税是多少?
  • 出租无形资产的收入
  • 房地产商品房销售营业税怎么算
  • 外贸企业当期认证的发票没申报影响退税吗?
  • 专票开户行和账号必须填吗
  • 停车管理费收费依据
  • 高危行业企业探索实行什么制度
  • 国有划拨地是否能转让土地
  • 培训费是否能全额退款
  • 公司按揭购车
  • 简易计税方法的适用范围
  • 办公家具可以一次性抵扣吗?
  • 自然人股息红利免征个人所得税?
  • 社保已申报未缴费可以减员吗
  • 印刷费可以开哪些科目
  • 行政事业单位的营业执照叫什么
  • 单位房子可以卖吗
  • php字符串定义
  • PHP:apache_request_headers()的用法_Apache函数
  • linux如何配置ssh
  • 若依框架前后端一体化设计管理系统
  • 计提坏账准备的方法
  • php _dir_
  • php自定义header
  • 专家评审费可以由中标人支付吗
  • 跨年调整收入增值税怎么办
  • js调用函数的几种方法
  • php获取前一天的时间
  • unmount命令详解
  • node_sass
  • 员工出差过程中意外死亡算工伤吗
  • 跨年度的利息收入怎么做账
  • 企业对外报送的财务报表
  • 以房租入股股份怎么计算
  • 融资租赁利息一般多少
  • EOFError:EOF when reading a line
  • phpcms是什么
  • wordpress禁止更新插件
  • 本期转让不动产的销售额是什么意思
  • 销售收入未开票
  • 工业企业缴纳增值税吗
  • 电子承兑转出需要授权吗
  • 附加税怎么算出来的
  • 以前年度损益调整怎么做账
  • 自产赠送视同销售的成本如何确定?
  • 保险公司 返点
  • 单品毛利润计算方法
  • 外埠存款会计分录怎么写
  • 赞助支出属于什么科目
  • 低值易耗的管理制度
  • sql server复制数据库的方法
  • linux下mysql开启远程访问权限 防火墙开放3306端口
  • windows10x预览版
  • windows10iot安装
  • appservicesdkscripterror
  • windows设置
  • 如何让windows7更快
  • 如何知道自己的邮箱号
  • 虚拟机安装win7一直卡在完成安装
  • hyper虚拟机连接外网
  • win8.1隐藏文件夹
  • Win10如何还原输入法
  • Android Chronometer(定时器)
  • cocos2d android
  • nodejs cgi
  • jquery 案例
  • python生成矩阵的方法
  • javascript数据类型有哪些
  • js中unbind
  • js运行效率
  • 小规模企业所得税怎么算
  • 电子税务局做什么的
  • 市中区税务局办税大厅上班时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设