首先说一下信息收件人这个类的继承关系

RecipientsEditor->EncapsulatedMTKRecipientEditTextView(这两个类都在mms目录下)

->MTKRecipientEditTextView(mediatek/frameworks-ext/ex/chips/src/com/android/ex/chips/)

->MultiAutoCompleteTextView->AutoCompleteTextView->EditText(frameworks/base/core/java/android/widget)

然后我们想要修改这个输入框的样式,包括里面的文字颜色、背景等。这个我们可以在MTKRecipientEditTextView 中进行设定,关键代码如下

 private Bitmap createUnselectedChip(RecipientEntry contact, TextPaint paint,
boolean leaveBlankIconSpacer) {
// Ellipsize the text so that it takes AT MOST the entire width of the
// autocomplete text entry area. Make sure to leave space for padding
// on the sides.
int height = (int) mChipHeight;
int iconWidth = height;
float[] widths = new float[1];
paint.getTextWidths(" ", widths);
/// M: Limit ellipsizedText in some case (ex. moreChip)
CharSequence ellipsizedText = ellipsizeText(createChipDisplayText(contact), paint,
(mLimitedWidthForSpan == -1) ? (calculateAvailableWidth() - iconWidth - widths[0]) : (mLimitedWidthForSpan - iconWidth - widths[0]));
printDebugLog(TAG,"[createUnselectedChip] start, " + ellipsizedText + ", ID: " + contact.getContactId());
// Make sure there is a minimum chip width so the user can ALWAYS
// tap a chip without difficulty. /// M: Only leave space if icon exists. @{
boolean hasIcon = false;
int ellipsizedTextWidth = (int) Math.floor(paint.measureText(ellipsizedText, 0, ellipsizedText.length()));
int width = ellipsizedTextWidth + (mChipPadding * 2);
/// @} // Create the background of the chip.
Bitmap tmpBitmap = null;
Drawable background = getChipBackground(contact);
if (background != null) {
Canvas canvas = null; /// M: Only leave space if icon exists
Bitmap photo = null;
Matrix matrix = null; // Don't draw photos for recipients that have been typed in OR generated on the fly.
long contactId = contact.getContactId();
boolean drawPhotos = isPhoneQuery() ?
contactId != RecipientEntry.INVALID_CONTACT
: (contactId != RecipientEntry.INVALID_CONTACT
&& (contactId != RecipientEntry.GENERATED_CONTACT &&
!TextUtils.isEmpty(contact.getDisplayName())));
if (drawPhotos) {
byte[] photoBytes = contact.getPhotoBytes();
// There may not be a photo yet if anything but the first contact address
// was selected.
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getPhoto " + contact.getContactId());
if (photoBytes == null && contact.getPhotoThumbnailUri() != null) {
// TODO: cache this in the recipient entry?
((BaseRecipientAdapter) getAdapter()).fetchPhoto(contact, contact
.getPhotoThumbnailUri());
photoBytes = contact.getPhotoBytes();
}
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "decodePhoto");
if (photoBytes != null) {
/* Vanzo:zhangshuli on: Thu, 12 Mar 2015 11:48:23 +0000
photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length);
*/
// End of Vanzo: zhangshuli
} else {
// TODO: can the scaled down default photo be cached?
/* Vanzo:zhangshuli on: Thu, 12 Mar 2015 11:48:28 +0000
photo = mDefaultContactPhoto;
*/
// End of Vanzo: zhangshuli
}
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
// Draw the photo on the left side.
if (photo != null) {
/// M: Only leave space if icon exists. @{
hasIcon = true;
width = ellipsizedTextWidth + (mChipPadding * 2) + iconWidth;
/// @}
RectF src = new RectF(0, 0, photo.getWidth(), photo.getHeight());
Rect backgroundPadding = new Rect();
mChipBackground.getPadding(backgroundPadding);
RectF dst = new RectF(width - iconWidth + backgroundPadding.left,
0 + backgroundPadding.top,
width - backgroundPadding.right,
height - backgroundPadding.bottom);
matrix = new Matrix();
matrix.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
}
} else if (!leaveBlankIconSpacer || isPhoneQuery()) {
iconWidth = 0;
} tmpBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
canvas = new Canvas(tmpBitmap); background.setBounds(0, 0, width, height);
background.draw(canvas);
if (photo != null && matrix != null) {
canvas.drawBitmap(photo, matrix, paint);
} /* Vanzo:shangxiaopeng on: Wed, 28 May 2014 11:03:56 +0800
* modify settings fun
paint.setColor(getContext().getResources().getColor(android.R.color.black));
*/
paint.setColor(getContext().getResources().getColor(android.R.color.white));
// End of Vanzo: shangxiaopeng
// Vertically center the text in the chip.
int xPositionOfText = hasIcon ? mChipPadding : (mChipPadding + (width - mChipPadding*2 - ellipsizedTextWidth)/2); /// M: Horizontally center the text in the chip
canvas.drawText(ellipsizedText, 0, ellipsizedText.length(), xPositionOfText,
getTextYOffset((String)ellipsizedText, paint, height), paint);
} else {
Log.w(TAG, "Unable to draw a background for the chips as it was never set");
} if (tmpBitmap == null) {
tmpBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
}
printDebugLog(TAG,"[createUnselectedChip] end");
return tmpBitmap;
}

但是,如果我们想要更改下拉框的布局,你会发现,无论你怎么在mediatek下修改都是没有效果的。后来发现要在它的父类中进行修改 AutoCompleteTextView

代码如下

 public void showDropDown() {
buildImeCompletions(); if (mPopup.getAnchorView() == null) {
if (mDropDownAnchorId != View.NO_ID) {
mPopup.setAnchorView(getRootView().findViewById(mDropDownAnchorId));
} else {
mPopup.setAnchorView(this);
}
}
if (!isPopupShowing()) {
// Make sure the list does not obscure the IME when shown for the first time.
mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
mPopup.setListItemExpandMax(EXPAND_MAX);
}
mPopup.show();
mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
/* Vanzo:zhangshuli on: Wed, 11 Mar 2015 20:27:52 +0000
*/
mPopup.getListView().setPadding(0, 0, mPopupMargnRight, 0);
if (mPopupMargnRight != 0){
mPopup.getListView().setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_OVERLAY);
}
// End of Vanzo: zhangshuli
}

这个代码是修改下拉框滚动条样式跟listview中item的边距

这里面用到了关于添加自定义属性的方法,参照另一篇文章

RecipientsEditor-信息收件人输入框的更多相关文章

  1. TKinter之输入框

    输入框是 Entry,应用程序要取得用户的信息,输入框是必不可少的. 输入框比较重要的一个函数: get:返回值即输入框的内容 比如e是一个输入框,e['show']='*'就变成了密码框 小例子:用 ...

  2. Autocomplete 自动补全(Webform实战篇)

    开篇语 因为项目中需要用到一个自动补全的功能,功能描述: 需求一:新增收件人的时候,自动下拉显示出数据库中所有的收件人信息(显示的信息包括:姓名-收件地址-联系方式) 需求二:选中一个值得时候,分别赋 ...

  3. Selenium+Python之163邮件发送

    今晚写了一个163邮箱登录的脚本,由于不停的访问163登录主页导致直接访问163邮箱主页登录需要输入验证码,因为无法获取到验证码,就这导致直接访问主页登录脚本不可行,为了绕过验证码,现在先访问hao1 ...

  4. 【框架】PageObject(一)

    1.目的:为了将元素的find方法和业务逻辑分开来.如果元素的页面位置发生了变化,只需改动一个文件,而不影响业务的实现. 2.原理:一般一个页面对应一个class,在class里描述所有要用到的web ...

  5. python webdriver 登录163邮箱发邮件加附件, 外加数据和程序分离,配置文件的方式

    配置文件:UiObjectMapSendMap.ini用来存放配置信息 GetOptionSendMail.py 用来读取配信息 #encoding=utf-8from selenium.webdri ...

  6. 二、jenkins配置email(以腾讯企业qq为例)

    废话不多说,直接上干货: 主要针对两个部分进行介绍: 1.jenkins内置的邮件功能: 2.Editable Email Notification插件的邮件功能: 低版本的jenkins有很多插件都 ...

  7. [入门级] 基于 visual studio 2010 mvc4 的图书管理系统开发初步 (二)

    [入门级] 基于 visual studio 2010 mvc4 的图书管理系统开发初步 (二) Date  周六 10 一月 2015 By 钟谢伟 Category website develop ...

  8. React Native实例之房产搜索APP

    React Native 开发越来越火了,web app也是未来的潮流, 现在react native已经可以完成一些最基本的功能. 通过开发一些简单的应用, 可以更加熟练的掌握 RN 的知识. 在学 ...

  9. Yii表单验证

    我之前在朋友的公司拿到他们oa的代码,发现是用Yii写的,oa系统比较简单,但是程序员对Yii的运用比较好,我拿来学习一下.如果有需要,我可以私下分享这个程序,因为是人家的功劳,不在网上公布代码了,只 ...

随机推荐

  1. 【Round #36 (Div. 2 only) C】Socks Pairs

    [题目链接]:https://csacademy.com/contest/round-36/task/socks-pairs/ [题意] 给你n种颜色的袜子,每种颜色颜色的袜子有ai只; 假设你在取袜 ...

  2. 使用JEECG心得

    使用JEECG心得 我就不做JEECG的介绍了,提供一个网址.能够更加清晰的了解JEECG文档. http://www.jeecg.org/book/jeecg_v3.html 用JEECG已经几乎相 ...

  3. “Vbox安装CentOS系统”之低级错误一例:版本号的选择

    日        期:2014年7月18日 错误描写叙述:虚拟机系统版本号选择错误,导致无法引导进入光盘安装 错误重演: 因为混淆了centos和rehat的版本号概念.错把centos作为一种新的版 ...

  4. Fragment的实际开发中总结(二)

    在实际项目的开发过程Fragment的情况越来越多.大家肯定须要遇到过Fragment被销毁重建的情况. 结合自己在项目开发的一点总结和学习开源项目的代码.继续分享自己对Fragment的一点总结. ...

  5. 五大最受欢迎的BUG管理系统

    Google在中国大陆遭遇变故做出临时性的退出大陆市场,也使非常多忠实的用户受到小小的挫折,以本公司为例.原本的BUG都是记录在google的 EXCEL在线文档中,由于常常性的打不开.測试和开发组在 ...

  6. 跨域post 及 使用token防止csrf 攻击

    环境: 后台使用的python - flask 前台使用angular框架 1.一个跨域post的样例: 跨域post有多种实现方式: 1.CORS:http://blog.csdn.net/hfah ...

  7. Android Private Libraries 和 Dependencies的区别

    Android项目开发中,是不是常看到android-support-v4.jar.appcompat_v7.jar等的jar包? 至于为什么要添加这些包?添加有什么用?添加到哪里?相信很多人没过多关 ...

  8. 关于Hive在主节点上与不在主节点上搭建的区别之谈

    Hive不在主节点上搭建,我这里是在HadoopSlave1上.

  9. 安装oracle常见问题分析

    1,之前已经安装过软件,卸载不完全 /tmp/.oracle /tmp/ora* /var/tmp/ora* /etc/ora* 2,安装介质权限或者本身就有问题 3,oracle用户 $/HOME/ ...

  10. Ubuntu16.04+Gnome3 锁定屏幕快捷键无效解决办法

    Ubuntu16.04 桌面环境通过Ubuntu server和后安装的Gnome3 桌面环境实现,安装完以后发现锁定屏幕快捷键无效,系统设置=>键盘=>快捷中 锁屏快捷键已经存在Supe ...