1,关于text和drawableTop之类的间距
android:drawablePadding="10dp"
java代码里设置自定义的字体颜色
counetdownView.setTextColor(mContext.getColorStateList(R.color.text_pre_white_to_gary));
listView
2,商城分类浏览
列表单选效果
去掉分割线
设置list模式(含多个)
默认选中第一个
3,edittext属性
Android:phoneNumber=”true” //输入电话号
android:maxLength=“50” 字数限制
Android:editable // 是否可编辑
代码中清除焦点-不会改变编辑状态
edittext.clearFocus();
在EditText中软键盘的调起、关闭
android:focusable="false"//禁止获取焦点
在父布局设置以下两个属性,取消默认获取焦点
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="false" 隐藏光标
android:background="#00000000"//不要文本框背景
android:numeric来控制输入的数字类型,一共有三种分别为integer(正整数)、signed(带符号整数,有正负)和decimal(浮点数)。
软键盘的调起导致原来的界面被挤上去,或者导致界面下面的tab导航被挤上去,解决方法如下
解决方法:
使用Manifest中的Activity的android:windowSoftInputMode的"adjustPan"属性。
另外注意:有关软键盘的问题可参考android:windowSoftInputMode中属性。
(1)EditText有焦点(focusable为true)阻止输入法弹出
editText=(EditText)findViewById(R.id.txtBody);
editText.setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View v, MotionEvent event){
editText.setInputType(InputType.TYPE_NULL); //关闭软键盘
return false;
}
});
当EidtText无焦点(focusable=false)时阻止输入法弹出
InputMethodManager imm =
(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(),0);
//关闭键盘(比如输入结束后执行) InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(etEditText.getWindowToken(), 0);
//自动弹出键盘
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
etEditText.requestFocus();//让EditText获得焦点,但是获得焦点并不会自动弹出键盘
,4,用于RecyclerView的adapter刷新数据,只有把新的数据传到adapter里然后notifyDataSetChanged()就可以了,如果数据很多,当然也有针对单条的数据更改
public void refresh(List<Variety> list) {
mVarietyList = list;
notifyDataSetChanged();//刷新全部数据
//notifyItemInserted(1); 新添加一条
//notifyItemRemoved(1);删除一条
}
5、ImageView图片位置
http://www.cnblogs.com/pandapan/p/4614837.html
6.如果滑动里嵌套列表,事件冲突 ,如果列表只是用于显示,最简单的就是把列表控件的事件取消
mRecyclerView.setNestedScrollingEnabled(false);
7.SearchView使用,搜索后由展开到关闭(缩小)
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//query:输入框内容
//设置两次setIconified是为了让searchView收缩
searchView.setIconified(true);//设置一次是清空内容
searchView.setIconified(true);//缩小
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});