1.EditText不显示光标

 开发的时候遇到有部分手机,小米系列以及华为部分手机不显示光标。

 设置EditText属性 

    android:textCursorDrawable="@null"
android:cursorVisible="true"

 可参考,http://stackoverflow.com/questions/15093758/edittext-cursor-is-invisible-in-android-4-0第一个回答。

 附上我自己封装的一个方法

 

 private final static String TAG = "EditTextCompat";

     /**
* 设置光标可见 <br/>
* 此处为了解决部分手机(如小米、华为)无法显示光标的问题,由于编译环境为2.3,导致部分函数无法调用,此处使用反射调用<br/>
*/
public static void setCursorVisible(EditText editText, Context context) {
editText.setCursorVisible(true);
// sdk
// 对应关系表,见http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
if (android.os.Build.VERSION.SDK_INT >= 12) {// Android 3.1.x API12
// HONEYCOMB_MR1
String filedNameString = "mCursorDrawableRes";
// mCursorDrawableRes
Class<? extends EditText> editTextClass = editText.getClass();
Class<? extends TextView> textViewClass = null;
if (editTextClass != null) {
textViewClass = (Class<? extends TextView>) editTextClass
.getSuperclass();
}
if (textViewClass != null) {
Field mCursorDrawableField = null;
try {
mCursorDrawableField = textViewClass
.getDeclaredField(filedNameString);
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
Log.i(TAG, "NoSuchFieldException");
e.printStackTrace();
}
if (mCursorDrawableField != null) {
mCursorDrawableField.setAccessible(true);
try {
mCursorDrawableField.set(editText, 0); } catch (IllegalArgumentException e) {
Log.i(TAG, "IllegalArgumentException");
e.printStackTrace();
} catch (NotFoundException e) {
Log.i(TAG, "NotFoundException");
e.printStackTrace();
} catch (IllegalAccessException e) {
Log.i(TAG, "IllegalAccessException");
e.printStackTrace();
}
} }
}
}
}

 2.AutoCompleteTextView在部分手机(如联想a860e)显示黑条。

  见图

  

  解决方案:在themes.xml设置一个主题,设置它的android:dropDownListViewStyle属性。

  <style name="search_theme" parent="android:style/Theme.NoTitleBar">
<item name="android:dropDownListViewStyle">@style/widget_dropdownlistview</item>
</style>

  在styles.xml中定义下面字段。

   <style name="widget_dropdownlistview" parent="android:style/Widget.Holo.ListView.DropDown">
<item name="android:scrollbars">none</item>
<item name="android:divider">@color/white</item>
</style>

  对需要用到AutoCompleteTextView的Activity设置主题(AndroidManifest.xml中设置)。

  然后样式就OK了。

  如图

  

可参考http://www.apkbus.com/android-126131-1-1.html

3.Dialog在部分手机上显示黑条

  设置

  

  <item name="android:windowContentOverlay">@null</item>

  可参考。http://www.cnblogs.com/kaima/archive/2011/07/29/2121457.html

最新文章

  1. leetcode-99 Recover_Binary_Search_Tree
  2. python杂记-3(购买商品)
  3. css样式编辑
  4. 【Linux远程管理】RDP协议远程管理
  5. 用C#来查看电脑硬件和系统信息
  6. sql语句读取所有父子标签
  7. Linux下javaweb
  8. Extjs4中的常用组件:Grid、Tree和Form
  9. web前端概念巩固(一)
  10. 在Ubuntu16.04上部署LXC容器管理系统的相关步骤
  11. weblogic找不到数据源
  12. numpy+plot初试
  13. 2018-2019-2 网络对抗技术 20165228 Exp6 信息搜集与漏洞扫描
  14. Mysql线程池系列一:什么是线程池和连接池( thread_pool 和 connection_pool)
  15. 01: RestfulAPI与HTTP
  16. docker容器中搭建kafka集群环境
  17. C++运算符重载三种形式(成员函数,友元函数,普通函数)详解
  18. Java 运行时数据区域
  19. BZOJ2118:墨墨的等式(最短路)
  20. 温习js中对象的继承

热门文章

  1. GCC编译器入门
  2. mysql---union的用法
  3. 一个css3流程导图
  4. normalize.css介绍
  5. sencha architect/sencha touch , to prevent breakpoint lost when you debug
  6. Twitter:蓄水池储水量问题
  7. WCF 消息压缩性能问题及解决方法
  8. String类的split方法以及StringTokenizer
  9. Python 标准库 urllib2 的使用细节
  10. HDU 2370 Convert Kilometers to Miles