在使用EditText进行文本输入时,若不进行特殊的设置,使用Android自带的软键盘,该软键盘会占用整个界面,那么,如何让键盘只占用屏幕的一部分呢?
Xml代码 收藏代码

 <EditText           android:id="@+id/text1"           android:layout_width="150dip"           android:layout_height="wrap_content"          android:imeOptions="flagNoExtractUi"/>  


使用android:imeOptinos可对Android自带的软键盘进行一些界面上的设置:
Java代码 收藏代码

 android:imeOptions="flagNoExtractUi"  //使软键盘不全屏显示,只占用一部分屏幕      同时,这个属性还能控件软键盘右下角按键的显示内容,默认情况下为回车键      android:imeOptions="actionNone"  //输入框右侧不带任何提示      android:imeOptions="actionGo"    //右下角按键内容为'开始'      android:imeOptions="actionSearch"  //右下角按键为放大镜图片,搜索      android:imeOptions="actionSend"    //右下角按键内容为'发送'      android:imeOptions="actionNext"   //右下角按键内容为'下一步'      android:imeOptions="actionDone"  //右下角按键内容为'完成'   


同时,可能EditText添加相应的监听器,捕捉用户点击了软键盘右下角按钮的监听事件,以便进行处理。
Java代码 复制代码 收藏代码

 editText.setOnEditorActionListener(new OnEditorActionListener() {               @Override              public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {                   Toast.makeText(MainActivity.this, "text2", Toast.LENGTH_SHORT).show();                   return false;               }           });  




补充内容:
1.在string.xml里设置某一部分内容字体颜色

<string name="test"><Data><![CDATA[ <b><font color="#ff0000">ABC</font></b> ]]></Data></string>  

注:<b>是字体加粗
使用方法如下:
 textView.setText(getString(R.string.test));


2.图片格式转换:

1.Drawable—>Bitmap

Resources res=getResources();Bitmap bmp=BitmapFactory.decodeResource(res, R.drawable.sample_0);


2.Bitmap---->Drawable

Drawable drawable =new BitmapDrawable(bmp);



3、Drawable → Bitmap

public static Bitmap drawableToBitmap(Drawable drawable) {               Bitmap bitmap = Bitmap.createBitmap(                                        drawable.getIntrinsicWidth(),                                        drawable.getIntrinsicHeight(),                                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888                                                        : Bitmap.Config.RGB_565);        Canvas canvas = new Canvas(bitmap);        //canvas.setBitmap(bitmap);        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());        drawable.draw(canvas);        return bitmap;}


4、从资源中获取Bitmap

Bitmap bmp=BitmapFactory.decodeResource(res, R.drawable.pic);


5、Bitmap → byte[]

 ByteArrayOutputStream baos = new ByteArrayOutputStream();    bm.compress(Bitmap.CompressFormat.PNG, 100, baos);    return baos.toByteArray();   }


6、 byte[] → Bitmap

private Bitmap Bytes2Bimap(byte[] b){                    if(b.length!=0){                            return BitmapFactory.decodeByteArray(b, 0, b.length);                    }                    else {                            return null;                    }          }

更多相关文章

  1. android EditText imeOptions属性和各属性setOnEditorActionList
  2. Android(安卓)使用android:inputType属性,从EditText中输入获取数
  3. Android(安卓)更改软键盘Enter键为搜索
  4. Android(安卓)软键盘弹出,界面整体上移
  5. android EditText控件自动获取焦点弹出键盘解决方法
  6. Android禁止EditText自动弹出软键盘的方法
  7. android EditText 的键盘弹出(不弹出)坑爹
  8. Android平台上面输入法遮挡问题-android:windowSoftInputMode属
  9. Android横竖屏切换

随机推荐

  1. Android spinner取Value和Text的值
  2. android传感器过滤,取中间直, 方位角介绍
  3. unity 导出 android安装包配置方案
  4. 彻底解决android surfaceview下触摸和键
  5. Android 学习之简单的底部弹出dialog
  6. android tips—开机引导启动wifi设置
  7. tabHost研究二 ,android应用中,大部分的软
  8. 讲一讲对Activity的了解【Android】
  9. React-Native 报错 Error: EISDIR: illeg
  10. Android 状态栏和应用标题栏颜色保持一致