theme- 自定义控件属性
今天想要在一个控件中增加自己的一条属性,具体步骤如下
1.在frameworks/base/core/res/res/values/attr中注册属性
因为我们希望增加的属性是在AutoCompleteTextView中,所以我们添加如下
<declare-styleable name="AutoCompleteTextView">
<!-- Defines the marginright in the drop down menu. -->
<attr name="dropDownListItemPaddingRight" format="dimension" />
<!-- Defines the hint displayed in the drop down menu. -->
<attr name="completionHint" format="string" />
<!-- Defines the hint view displayed in the drop down menu. -->
<attr name="completionHintView" format="reference" />
<!-- Defines the number of characters that the user must type before
completion suggestions are displayed in a drop down menu. -->
<attr name="completionThreshold" format="integer" min="1" />
<!-- Selector in a drop down list. -->
<attr name="dropDownSelector" format="reference|color" />
<!-- Amount of pixels by which the drop down should be offset vertically. -->
<attr name="dropDownVerticalOffset" format="dimension" />
<!-- Amount of pixels by which the drop down should be offset horizontally. -->
<attr name="dropDownHorizontalOffset" format="dimension" />
<!-- View to anchor the auto-complete dropdown to. If not specified, the text view itself
is used. -->
<attr name="dropDownAnchor" format="reference" />
</declare-styleable name="AutoCompleteTextView">
2.代码中引用
主要是在AutoCompleteTextView.java
TypedArray a =
context.obtainStyledAttributes(
attrs, com.android.internal.R.styleable.AutoCompleteTextView, defStyle, 0);
mPopupMargnRight = (int) a.getDimension(R.styleable.AutoCompleteTextView_dropDownListItemPaddingRight, 0.0f);
3.style 中设定属性值
<style name="Widget.Funui.AutoCompleteTextView" parent="Widget.AutoCompleteTextView">
<item name="android:dropDownSelector">@android:drawable/list_selector_funui</item>
<item name="android:popupBackground">@android:drawable/menu_dropdown_panel_funui</item>
<item name="android:dropDownListItemPaddingRight">13dp</item>
</style>
theme- 自定义控件属性的更多相关文章
- c#自定义控件属性面板及选择资源设置
博客转移到 http://jacean.github.io/ 继续分享编程经验 因为要做流体布局,但两个控件没办法组合,就做自定义控件.这个控件需要一个text设置文本,一个pic设置图片显示,图片通 ...
- Qt编写自定义控件属性设计器
以前做.NET开发中,.NET直接就集成了属性设计器,VS不愧是宇宙第一IDE,你能够想到的都给你封装好了,用起来不要太爽!因为项目需要自从全面转Qt开发已经6年有余,在工业控制领域,有一些应用场景需 ...
- winform 自定义控件属性在属性面板中显示
Jan.David Nothing is impossible, the word itself says 'I'm possible'!" — Audrey Hepburn winform ...
- c# 用户控件,usercontrol,自定义控件属性
1.C#用户控件的使用 2.拖动添加:画面上如需多个usercontrol,添加TableLayoutPanel,然后在工具箱中找到usercontrol,拖到相应框中 3.代码添加:主窗口中有多个T ...
- android自定义控件(1)-自定义控件属性
那么还是针对我们之前写的自定义控件:开关按钮为例来说,在之前的基础上,我们来看看有哪些属性是可以自定义的:按钮的背景图片,按钮的滑块图片,和按钮的状态(是开还是关),实际上都应该是可以在xml文件中直 ...
- Xcode 属性面板添加自定义控件属性
让自定义控件像原生控件一样可以在属性面板配置参数,Apple文档传送 直接上效果图,根据
- activity theme parent 属性浅析
在AndroidManifest.xml文件中,可以对每一个Activity设置android:themetheme的设置 可以设置为系统自带的格式,也可以自定义格式. A: 系统自带格式 1.and ...
- 安卓自定义View(一)自定义控件属性
自定义View增加属性第一步:定义属性资源文件 在/res/values 文件夹下建立"Values XML layout",按照如下定义一个textview的属性 <?xm ...
- [转]C#自定义控件属性与行为
原文链接:http://blog.csdn.net/a237428367/article/details/5926445 控件应该定义属性而不是公共字段,因为可视化设计器在属性浏览器中显示属性,而不显 ...
- android自定义控件属性
有两种方法为自定义的控件设置属性 . 来自为知笔记(Wiz)
随机推荐
- Unity C# 设计模式(四)抽象工厂模式
定义: 提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类. 工厂方法模式针对的是一个产品等级结构:而抽象工厂模式针对的是多个产品等级结构. 抽象工厂模式使用同一个 工厂等级结构负责这 ...
- 05-数据类型转换(bool转换)
05-数据类型转换(bool转换)
- 01-JS起步
01-JS起步
- 【转】 基于C#.NET的高端智能化网络爬虫
[转] 基于C#.NET的高端智能化网络爬虫 前两天朋友发给我了一篇文章,是携程网反爬虫组的技术经理写的,大概讲的是如何用他的超高智商通过(挑衅.怜悯.嘲讽.猥琐)的方式来完美碾压爬虫开发者.今天我就 ...
- 【转】C# HttpWebRequest提交数据方式
[转]C# HttpWebRequest提交数据方式 HttpWebRequest和HttpWebResponse类是用于发送和接收HTTP数据的最好选择.它们支持一系列有用的属性.这两个类位 于Sy ...
- 概率dp HDU 3853
H - LOOPS Time Limit:5000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ci ...
- UITextField监控文字变化方法
项目里须要在不隐藏键盘的情况下.来更改button 的状态. 这里就是要对uitextfield监控.uitextfield继承于UIControl.所以能够 使用addTarget方法.详细例如以下 ...
- Magento--判断checkout中是否使用了coupon code
在checkout页面中,如果想判断顾客是否有使用coupon code,可以通过checkout session来进行判断.以下代码会返回checkout中使用的coupon code或者返回空(当 ...
- XML解析——SAX解析以及更方便的解析工具(JDOM、DOM4J)
XML主要用于数据交换,HTML则用于显示. 相对于DOM的树形解析,SAX采用的是顺序解析,这种解析方法可以快速地读取XML数据的方式. SAX主要事件: No. 方法 类型 描述 1 public ...
- 【hdu 1429】胜利大逃亡(续)
[Link]: [Description] 给你一个n*m的格子; 里面有钥匙,以及钥匙能开的门; 以及墙,以及起点,以及出口; 问你从起点出发,到出口的话,能不能在t时间内到; [Solution] ...