Android 随笔(2)

1、TextView 

android:lineSpacingExtra="5dp"       设置行间距,如”3dp”。

android:lineSpacingMultiplier="1.2"    设置行间距的倍数,如”1.2″。

超出制定长度显示省略号

android:ellipsize="end"

android:maxEms="11"

android:singleLine="true"


2、CheckBox

<CheckBox

     android:id="@+id/checkbox"
     android:layout_width="25dp"
     android:layout_height="25dp"
     android:layout_centerVertical="true"
     android:layout_gravity="center_vertical"
     android:layout_marginLeft="@dimen/space_10"
     android:background="@drawable/checkbox"
     android:button="@null"
     android:checked="true" />


3、EditText

personalEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(number)});   代码设置输入字数限制

android:maxLength="10"  XML设置输入字数限制

android:background="@null"   无背景

android:inputType="textMultiLine"  多行文本输入

password_edit.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);  密码可见

password_edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);  密码不可见

android:windowSoftInputMode="adjustPan"  (AndroidManifest.xml文件中对应的activity里面) 弹出软键盘,布局被上顶的问题

Android 如何让EditText不自动获取焦点

EditText的父级控件中找一个,设置成

    android:focusable="true"  
    android:focusableInTouchMode="true"

更多属性详见:http://blog.csdn.net/qyf_5445/article/details/8651740

//监听EditText输入
mLoginNameEditText.addTextChangedListener(new TextWatcher() {
         @Override
         public void beforeTextChanged(CharSequence s, int start, int count, int after) {
         }

         @Override
         public void onTextChanged(CharSequence s, int start, int before, int count) {
         }

        @Override
        public void afterTextChanged(Editable s) {
        }
});







猜你喜欢

转载自blog.csdn.net/wang_1220/article/details/54948232
今日推荐