一些有用的开发问题整理

android:textColorHint="#ffff00"
  设置提示信息文字的颜色,默认为灰色
  android:textScaleX="1.5"
  控制字与字之间的间距
  android:typeface="monospace"
  字型,normal, sans, serif, monospace
  android:background="@null"
  空间背景,这里没有,指透明
  android:layout_weight="1"
  权重,控制控件之间的地位,在控制控件显示的大小时蛮有用的。
  android:textAppearance="?android:attr/textAppearanceLargeInverse"
  EditText始终不弹出软件键盘

        1.EditText默认不弹出软件键盘

   方法一:
  在 AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden

java代码:

  1. < activity android:name=".Main"
  2. android:label="@string/app_name"
  3. android:windowSoftInputMode="adjustUnspecified|stateHidden"
  4. android:configChanges="orientation|keyboardHidden">
  5. < intent-filter>
  6. < action android:name="android.intent.action.MAIN" />
  7. < category android:name="android.intent.category.LAUNCHER" />
  8. < /intent-filter>
  9. < /activity>



        方法二:   让 EditText失去焦点,使用EditText的clearFocus方法
  例如:EditText edit=(EditText)findViewById(R.id.edit);
  edit.clearFocus();

   方法三:
  强制隐藏Android输入法窗口
  例如:EditText edit=(EditText)findViewById(R.id.edit);
  InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(edit.getWindowToken(),0);

二:如何对EditText进行setText()的时候使其自动换行 

Java代码 
<EditText android:layout_width="200dp" android:layout_height="wrap_content"  
        android:id="@+id/input" android:singleLine="false"   
         />  

  我们只要确保singleLine为false的话,并且设置宽度一定,就可以自动换行,注意在这里不要设置
Java代码 
input.setInputType(0);  

不然就不会自动换行 

2.在TableLayout中布局一行,设置EditText的xml属性: 
Java代码 
<!-- android:shrinkColumns="1" shrinks the 2nd column to fit the window -->  
<!-- android:stretchColumns="1" stretches the 2nd column -->  
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="fill_parent" android:layout_height="fill_parent"  
    android:orientation="vertical" android:paddingLeft="5dp"  
    android:paddingRight="5dp" android:stretchColumns="1">  
  
  
    <TableRow android:layout_width="fill_parent"  
        android:layout_height="wrap_content" android:orientation="horizontal">  
        <TextView android:layout_width="wrap_content"  
            android:layout_height="wrap_content" android:text="Email"  
            android:paddingRight="5dp">  
        </TextView>  
        <EditText android:id="@+id/txtEmail" android:layout_width="200dp"  
            android:layout_height="wrap_content" android:textSize="18sp"  
            android:singleLine="false" android:inputType="textEmailAddress">  
        </EditText>  
    </TableRow>  
  
  
</TableLayout>   


3.如何设置EditText隐藏键盘 

Java代码 
(EditText)mMarket.setInputType(0);  


4.如何设置EditText不被输入法遮盖 
Java代码 
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值