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

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

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

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

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

  1. private Bitmap createUnselectedChip(RecipientEntry contact, TextPaint paint,
  2. boolean leaveBlankIconSpacer) {
  3. // Ellipsize the text so that it takes AT MOST the entire width of the
  4. // autocomplete text entry area. Make sure to leave space for padding
  5. // on the sides.
  6. int height = (int) mChipHeight;
  7. int iconWidth = height;
  8. float[] widths = new float[1];
  9. paint.getTextWidths(" ", widths);
  10. /// M: Limit ellipsizedText in some case (ex. moreChip)
  11. CharSequence ellipsizedText = ellipsizeText(createChipDisplayText(contact), paint,
  12. (mLimitedWidthForSpan == -1) ? (calculateAvailableWidth() - iconWidth - widths[0]) : (mLimitedWidthForSpan - iconWidth - widths[0]));
  13. printDebugLog(TAG,"[createUnselectedChip] start, " + ellipsizedText + ", ID: " + contact.getContactId());
  14. // Make sure there is a minimum chip width so the user can ALWAYS
  15. // tap a chip without difficulty.
  16.  
  17. /// M: Only leave space if icon exists. @{
  18. boolean hasIcon = false;
  19. int ellipsizedTextWidth = (int) Math.floor(paint.measureText(ellipsizedText, 0, ellipsizedText.length()));
  20. int width = ellipsizedTextWidth + (mChipPadding * 2);
  21. /// @}
  22.  
  23. // Create the background of the chip.
  24. Bitmap tmpBitmap = null;
  25. Drawable background = getChipBackground(contact);
  26. if (background != null) {
  27. Canvas canvas = null; /// M: Only leave space if icon exists
  28. Bitmap photo = null;
  29. Matrix matrix = null;
  30.  
  31. // Don't draw photos for recipients that have been typed in OR generated on the fly.
  32. long contactId = contact.getContactId();
  33. boolean drawPhotos = isPhoneQuery() ?
  34. contactId != RecipientEntry.INVALID_CONTACT
  35. : (contactId != RecipientEntry.INVALID_CONTACT
  36. && (contactId != RecipientEntry.GENERATED_CONTACT &&
  37. !TextUtils.isEmpty(contact.getDisplayName())));
  38. if (drawPhotos) {
  39. byte[] photoBytes = contact.getPhotoBytes();
  40. // There may not be a photo yet if anything but the first contact address
  41. // was selected.
  42. Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getPhoto " + contact.getContactId());
  43. if (photoBytes == null && contact.getPhotoThumbnailUri() != null) {
  44. // TODO: cache this in the recipient entry?
  45. ((BaseRecipientAdapter) getAdapter()).fetchPhoto(contact, contact
  46. .getPhotoThumbnailUri());
  47. photoBytes = contact.getPhotoBytes();
  48. }
  49. Trace.traceEnd(Trace.TRACE_TAG_VIEW);
  50. Trace.traceBegin(Trace.TRACE_TAG_VIEW, "decodePhoto");
  51. if (photoBytes != null) {
  52. /* Vanzo:zhangshuli on: Thu, 12 Mar 2015 11:48:23 +0000
  53. photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length);
  54. */
  55. // End of Vanzo: zhangshuli
  56. } else {
  57. // TODO: can the scaled down default photo be cached?
  58. /* Vanzo:zhangshuli on: Thu, 12 Mar 2015 11:48:28 +0000
  59. photo = mDefaultContactPhoto;
  60. */
  61. // End of Vanzo: zhangshuli
  62. }
  63. Trace.traceEnd(Trace.TRACE_TAG_VIEW);
  64. // Draw the photo on the left side.
  65. if (photo != null) {
  66. /// M: Only leave space if icon exists. @{
  67. hasIcon = true;
  68. width = ellipsizedTextWidth + (mChipPadding * 2) + iconWidth;
  69. /// @}
  70. RectF src = new RectF(0, 0, photo.getWidth(), photo.getHeight());
  71. Rect backgroundPadding = new Rect();
  72. mChipBackground.getPadding(backgroundPadding);
  73. RectF dst = new RectF(width - iconWidth + backgroundPadding.left,
  74. 0 + backgroundPadding.top,
  75. width - backgroundPadding.right,
  76. height - backgroundPadding.bottom);
  77. matrix = new Matrix();
  78. matrix.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
  79. }
  80. } else if (!leaveBlankIconSpacer || isPhoneQuery()) {
  81. iconWidth = 0;
  82. }
  83.  
  84. tmpBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  85. canvas = new Canvas(tmpBitmap);
  86.  
  87. background.setBounds(0, 0, width, height);
  88. background.draw(canvas);
  89. if (photo != null && matrix != null) {
  90. canvas.drawBitmap(photo, matrix, paint);
  91. }
  92.  
  93. /* Vanzo:shangxiaopeng on: Wed, 28 May 2014 11:03:56 +0800
  94. * modify settings fun
  95. paint.setColor(getContext().getResources().getColor(android.R.color.black));
  96. */
  97. paint.setColor(getContext().getResources().getColor(android.R.color.white));
  98. // End of Vanzo: shangxiaopeng
  99. // Vertically center the text in the chip.
  100. int xPositionOfText = hasIcon ? mChipPadding : (mChipPadding + (width - mChipPadding*2 - ellipsizedTextWidth)/2); /// M: Horizontally center the text in the chip
  101. canvas.drawText(ellipsizedText, 0, ellipsizedText.length(), xPositionOfText,
  102. getTextYOffset((String)ellipsizedText, paint, height), paint);
  103. } else {
  104. Log.w(TAG, "Unable to draw a background for the chips as it was never set");
  105. }
  106.  
  107. if (tmpBitmap == null) {
  108. tmpBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  109. }
  110. printDebugLog(TAG,"[createUnselectedChip] end");
  111. return tmpBitmap;
  112. }

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

代码如下

  1. public void showDropDown() {
  2. buildImeCompletions();
  3.  
  4. if (mPopup.getAnchorView() == null) {
  5. if (mDropDownAnchorId != View.NO_ID) {
  6. mPopup.setAnchorView(getRootView().findViewById(mDropDownAnchorId));
  7. } else {
  8. mPopup.setAnchorView(this);
  9. }
  10. }
  11. if (!isPopupShowing()) {
  12. // Make sure the list does not obscure the IME when shown for the first time.
  13. mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
  14. mPopup.setListItemExpandMax(EXPAND_MAX);
  15. }
  16. mPopup.show();
  17. mPopup.getListView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
  18. /* Vanzo:zhangshuli on: Wed, 11 Mar 2015 20:27:52 +0000
  19. */
  20. mPopup.getListView().setPadding(0, 0, mPopupMargnRight, 0);
  21. if (mPopupMargnRight != 0){
  22. mPopup.getListView().setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_OVERLAY);
  23. }
  24. // End of Vanzo: zhangshuli
  25. }

这个代码是修改下拉框滚动条样式跟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. Express的初步使用

    废话不多说直接上步骤: 1. 首先建立一个新文件夹,进入此文件夹的命令窗口通过 npm init 命令为你的应用创建一个           package.json 文件,然后下载express模块 ...

  2. IPMI远程管理一点记录

    http://www.07net01.com/storage_networking/IPMIyuanchengguanliyidianjilu_53093_1357975254.html

  3. Android——4.2 - 3G移植之路之 APN (五)

    APN,这东西对于刚接触的人来说并非那么好理解.对于3G移植上网不可缺少,这里记录一下. 撰写不易,转载请注明出处:http://blog.csdn.net/jscese/article/detail ...

  4. Network Stack

    Network Stack 目录 1 Overview 2 Code Layout 3 Anatomy of a Network Request (focused on HTTP) 3.1 URLRe ...

  5. OpenSUSE Leap 42.3下通过Firefox Opera Chromium浏览器直接执行java应用程序(打开java jnlp文件)实现在服务器远程虚拟控制台完成远程管理的方法

    远程虚拟控制台依赖于java运行环境(jre),在通过浏览器打开链接前,系统必须安装jre环境,远程管理控制台其实就是一个java程序,打开相应的网站会下载一个jnlp(java网络加载协议)的文件, ...

  6. Codeforces Round #240 (Div. 2) 题解

    A: 1分钟题,往后扫一遍 int a[MAXN]; int vis[MAXN]; int main(){ int n,m; cin>>n>>m; MEM(vis,); ; i ...

  7. Ace在线编辑器使用requirejs配置

    Ace代码在线编辑器如果需要在requirejs里使用,注意需要使用github上lib/ace目录的文件. 如果使用ajaxorg/ace-builds下面的代码再使用requirejs会报错,不能 ...

  8. Idea下mybatis的错误—Module not specified

    IDEA下使用maven的mybatis常见错误 错误类型一:导入项目引起的错误Module not specified 错误提示:idea Error Module not specified. 错 ...

  9. 51nod 最大子段和问题

    给出一个整数数组a(正负数都有),如何找出一个连续子数组(可以一个都不取,那么结果为0),使得其中的和最大? 用f[i]表示以i为结尾的最大字段和,也就是说i一定要取, 那么f[i] = max(a[ ...

  10. RQNOJ PID496/[IOI1999]花店橱窗布置

    PID496 / [IOI1999]花店橱窗布置 ☆   题目描述 某花店现有F束花,每一束花的品种都不一样,同时至少有同样数量的花瓶,被按顺序摆成一行,花瓶的位置是固定的,从左到右按1到V顺序 编号 ...