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) {
        }
});







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章