开发常用代码记录
2017-03-17 10:42
337 查看
一、 去掉标题栏
1..在代码里实现 this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
// 隐藏状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN;
记住:这句代码要写在setContentView()前面。
2.在清单文件(manifest.xml)里面实现
这样用可以将整个应用设置成无标题栏,如果只需要在一个Activity设置成一个无标题栏的形式,只要把上面的第三行代码写到某一个Activity里面就可以了。
3.在style.xml文件里定义
然后面manifest.xml中引用就可以了,这种方法稍麻烦了些。
二、EditText与软件键盘
1.在AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden
2.让EditText失去焦点,使用EditText的clearFocus方法,如下:
3.强制隐藏Android输入法窗口
4.EditText始终不弹出软件键盘
三、获取状态栏高度
四、TextView添加自动滚动
五、PopuWindow
背景半透明
2.点击外部使popuwindow消失
仅作为记录,方便日后使用 (持续更新~)
1..在代码里实现 this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
// 隐藏状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN;
记住:这句代码要写在setContentView()前面。
2.在清单文件(manifest.xml)里面实现
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
这样用可以将整个应用设置成无标题栏,如果只需要在一个Activity设置成一个无标题栏的形式,只要把上面的第三行代码写到某一个Activity里面就可以了。
3.在style.xml文件里定义
<?xml version="1.0" encoding="UTF-8" ?> <resources> <style name="notitle"> <item name="android:windowNoTitle">true</item> </style> </resources> <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/notitle">
然后面manifest.xml中引用就可以了,这种方法稍麻烦了些。
二、EditText与软件键盘
1.在AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden
2.让EditText失去焦点,使用EditText的clearFocus方法,如下:
EditText edit=(EditText)findViewById(R.id.edit); edit.clearFocus();
3.强制隐藏Android输入法窗口
EditText edit=(EditText)findViewById(R.id.edit); InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edit.getWindowToken(),0);
4.EditText始终不弹出软件键盘
EditText edit=(EditText)findViewById(R.id.edit); edit.setInputType(InputType.TYPE_NULL);
三、获取状态栏高度
int result = 0; int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = context.getResources().getDimensionPixelSize(resourceId); }
四、TextView添加自动滚动
android:marqueeRepeatLimit="marquee_forever" android:ellipsize="marquee" android:singleLine="true" android:focusableInTouchMode="true" android:focusable="true"
五、PopuWindow
背景半透明
/** * 设置背景的透明度 * * @param alpha 0.0 - 1.0 1.0表示完全不透明 */ private void setAlpha(float alpha){ WindowManager.LayoutParams attributes = getWindow().getAttributes(); attributes.alpha = alpha; getWindow().setAttributes(attributes); }
2.点击外部使popuwindow消失
window.setBackgroundDrawable(new ColorDrawable(0x00000000)); window.setOutsideTouchable(true);
仅作为记录,方便日后使用 (持续更新~)
相关文章推荐
- WEB编程开发常用的代码
- WEB编程开发常用的代码
- WEB编程开发常用的代码
- 由于上班需求申请博客记录常用代码
- [转]一些web开发中常用的、做成cs文件的js代码
- 蛙蛙推荐:最近开发一个小型的OA,把常用代码和大家分享一下先
- WEB编程开发常用的代码
- 开发常用网址记录
- WEB编程开发常用的代码
- web开发中常用的、做成cs文件的js代码
- WEB编程开发常用的代码
- WEB编程开发常用的代码
- 收集的WEB编程开发常用代码
- 移动开发常用代码
- WEB编程开发常用的代码
- WEB编程开发常用的代码[转载于CSDN文档中心]
- java代码框架生成工具 开发记录2005-03-02
- WEB编程开发常用的代码 ( 选择自 AppleBBS 的 Blog)
- B/S开发中常用javaScript技术与代码
- web开发中常用的、做成cs文件的js代码