位置: 编程技术 - 正文

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

  • 土地 税
  • 企业之间拆借资金是什么意思
  • 发票勾选认证必须对应当期成本吗
  • 进项税加计抵扣政策
  • 同一控制下长期股权投资相关税费
  • 调用系统服务出错核心征管后端
  • 六个点的税率是小规模吗
  • 自行建造固定资产中的自营工程,在领用工程物资
  • 支付结算有哪些工具
  • 现金比率一般多少
  • 未认证的进项也就是库存
  • 公司收到现金货款需要存入银行吗
  • 持有债券到期收到现金属于什么活动
  • 单位发生的业务怎么做账
  • 事业单位没有经过公示的内部文件不生效 出处
  • 建筑公司亏损异常怎么办
  • 哪些发票可以抵扣成本
  • 含税价与不含税价哪个便宜
  • 开票税率选错申报增值税时怎么处理
  • 高温补贴需要交个人所得税吗2019
  • 丧失控股权的后果
  • 苹果手机14pro max
  • 建筑公司收到工程款需要交哪些税
  • 收到员工水电费怎么做账
  • 应付票据包括哪些票
  • w10系统有线连接网络
  • 发散思维的关键
  • 公司和个人分别交什么税
  • PHP:Memcached::setSaslAuthData()的用法_Memcached类
  • thinkphp invoke
  • 开具增值税发票哪些情形不用交税?
  • 哈利法塔里面有什么
  • arthas常用命令
  • 收到现金股利会影响利润吗
  • 浏览器集成什么意思
  • 语音识别的正确流程
  • 发票章没有盖好
  • 垃圾处理费计提吗
  • 库存周转率会大于1吗
  • 非营利组织如何才能获得持续稳定的公益捐赠
  • mysql临时表什么时候销毁
  • 管理不善的进项税额去了哪里
  • 政府会计应付职工薪酬明细科目
  • 个税申报怎样作废
  • 如何把excel数据导入到word表格
  • SQL2005 provider: 命名管道提供程序 error: 40 无法打开到 SQL Server 的连接
  • server2003dns配置
  • 小规模纳税人地方教育费附加税率
  • 只有进项税月末要转入未交增值税么
  • 月末结存材料的实际成本例题
  • 同在一个单位
  • 企业所得税免税和减半征收
  • 质量问题的扣款计入什么科目
  • 损益类科目借贷怎么记
  • 付款退回在现金里怎么查
  • 合同负债包括
  • 个人向公司借款流程
  • 公司股权变更所需资金
  • 个体工商户个税怎么申报
  • 未达起征点的收入怎么入账
  • 税种工会经费
  • Win10系统任务栏一直转圈
  • xp系统 win7
  • macbook外接多个显示器
  • newsupd.exe - newsupd是什么进程 有什么用
  • 如何设置win10用户名
  • linux系统问题汇总
  • windows8 defender
  • win10系统锁屏广告怎么取消
  • linux内存耗尽怎么解决
  • 在windows窗口中以下叙述错误的是
  • eclipse cocos2dx Couldn't load cocos2dcpp from loader
  • jquery拖拽功能
  • 物理引擎演示
  • 安卓用什么抓包
  • jquery设置边框
  • python 举例
  • 成都市老年公交卡年审地点
  • 审批制改为备案制有什么区别
  • 小规模无票收入怎么报税
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设