- 浏览: 181176 次
- 性别:
- 来自: 武汉
-
文章分类
最新评论
-
beiizl:
用了博主的方法和代码,不同证书居然可以正常通讯?
Java SSLSocket的使用 -
SHANGLIJAVA:
sorry,运行时没看清。博主的代码确实没问题。。。
Java SSLSocket的使用 -
SHANGLIJAVA:
YoungeeOne 写道最后一个为什么初始化一个空的证书,也 ...
Java SSLSocket的使用 -
q979713444:
那这个的心跳怎么弄呢
Java SSLSocket的使用 -
43350860:
busybox不是每台机器有安装的, 有没有比较裸的办法获取p ...
android中查看端口占用
1. 自定义标题栏
1.1 常规自定义标题栏
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
自定义Activity的标题栏(Titlebar)
http://www.189works.com/article-51509-1.html
本文仅用到了Window.FEATURE_CUSTOM_TITLE,
Window还有其他一些feature,比如FEATURE_CONTEXT_MENU,FEATURE_NO_TITLE,FEATURE_LEFT_ICON等。
下面是一个来自wfd的完整的例子
wfd中的首页布局文件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="false"> </ListView> <TextView android:id="@id/android:empty" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="还没有会议刷新看看" android:gravity="center_horizontal" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="90dp" android:gravity="center_horizontal" android:orientation="vertical" android:layout_alignParentBottom="true"> <Button android:text="发起会议" android:id="@+id/launch" android:layout_width="200dp" android:layout_height="wrap_content"></Button> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center"> <CheckBox android:id="@+id/use_password" android:text="" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="启用密码"></TextView> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/home_refresh_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="invisible" android:layout_centerInParent="true" android:gravity="center"> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content"></ProgressBar> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="正在寻找会议室" android:paddingLeft="3dp"></TextView> </LinearLayout> <LinearLayout android:id="@+id/home_join_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="invisible" android:layout_centerInParent="true" android:gravity="center"> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content"></ProgressBar> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="正在加入会议室" android:paddingLeft="3dp"></TextView> </LinearLayout> </RelativeLayout>
自定义title的布局
<?xml version="1.0" encoding="utf-8"?> <!-- 首页title布局 --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="horizontal" android:gravity="center_vertical" android:padding="3dp"> <ImageView android:id="@+id/home_app_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" android:paddingRight="5dip"></ImageView> <TextView android:id="@+id/home_app_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_name"></TextView> <LinearLayout android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="right" android:layout_gravity="center_vertical"> <ImageView android:id="@+id/home_refresh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/search_32" android:paddingRight="15dp"></ImageView> <ImageView android:id="@+id/home_options" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/gear_32"></ImageView> </LinearLayout> </LinearLayout> <TextView android:background="@drawable/divider" android:layout_height="1dip" android:layout_width="fill_parent"></TextView> </LinearLayout>
java代码
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.home); // 设置自定义的title getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.home_custom_title); // 添加一个footview // getListView().addFooterView( // LayoutInflater.from(this).inflate(R.layout.home_foot, null)); mAdapter = new MeetingRoomAdapter(); doAddTestData(); setListAdapter(mAdapter); mRefresh = (ImageView) findViewById(R.id.home_refresh); mOptions = (ImageView) findViewById(R.id.home_options); mRefreshBar = (LinearLayout) findViewById(R.id.home_refresh_bar); mJoinBar = (LinearLayout) findViewById(R.id.home_join_bar); mLaunch = (Button) findViewById(R.id.launch); mUsePwd = (CheckBox) findViewById(R.id.use_password); mUsePwd.setOnCheckedChangeListener(this); mRefresh.setOnClickListener(this); mOptions.setOnClickListener(this); mLaunch.setOnClickListener(this);
效果
1.2 PreferenceActivity的自定义标题栏
PreferenceActivity 自定义title栏出错
http://www.cnblogs.com/slider/archive/2011/11/11/2245149.html
开发WFD过程中也遇到这个"PreferenceActivity 自定义title栏出错"的问题。
经分析,主要原因是因为PreferenceActivity 跟一般Activity不同. PreferenceActivity 的onCreate方法里面执行了setContentView, 而这个方法必须在
requestWindowFeature之后执行。 反映到我们继承自PreferenceActivity 的具体代码中就是, requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)要在super.onCreate(savedInstanceState)前执行
代码如下
public class SettingsActivity extends PreferenceActivity implements Preference.OnPreferenceChangeListener { public static final String KEY_USERNAME = "username"; private EditTextPreference mUsername; @Override protected void onCreate(Bundle savedInstanceState) { // 注意, PreferenceActivity // 里面需要把这个放在super.onCreate(savedInstanceState)前面!!! requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.settings_custom_title); mUsername = (EditTextPreference) findPreference(KEY_USERNAME); mUsername.setSummary(getUsername()); mUsername.setText(getUsername()); mUsername.setOnPreferenceChangeListener(this); } @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { return super.onPreferenceTreeClick(preferenceScreen, preference); } private String getUsername() { String name = PrefUtil.get(this, PrefUtil.PREF_SETTINGS, KEY_USERNAME, Build.MODEL); return name; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference == mUsername) { String val = (String) newValue; Logger.d("val = " + val); if (val != null && !val.equals("") && !val.equals(getUsername())) { mUsername.setSummary(val); PrefUtil.set(this, PrefUtil.PREF_SETTINGS, KEY_USERNAME, mUsername.getText()); } } return false; } }
2. 标题栏进度条
http://qing.weibo.com/2617185797/9bff160533000f4l.html?retcode=6102
最关键的位置就是在setContentView之前添加下面的这行代码
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); //设置为圆形旋转进度条
或者
requestWindowFeature(Window.FEATURE_PROGRESS); //设置为水平进度条 注意标题栏的水平进度条最大值是10000,不用自己手动设置
3. Java代码中隐藏标题栏
在Activity.setCurrentView()之前调用此方法
private void hideTitle(){ //TODOAuto-generatedmethodstub requestWindowFeature(Window.FEATURE_NO_TITLE); }
4. Java代码中全屏
在Activity.setCurrentView()之前调用此方法
private void hideStatusBar(){ //TODOAuto-generatedmethodstub // 隐藏标题 requestWindowFeature(Window.FEATURE_NO_TITLE); // 定义全屏参数 intflag=WindowManager.LayoutParams.FLAG_FULLSCREEN; // 获得窗口对象 WindowmyWindow=this.getWindow(); // 设置 Flag标识 myWindow.setFlags(flag,flag); }
5. manifest中全屏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
6. manifest中隐藏标题栏
android:theme="@android:style/Theme.NoTitleBar"
7. 半透明风格的Activity
android:theme="@android:style/Theme.Translucent"
或者先编写一个color.xml
<?xmlversion="1.0"encoding="UTF-8"?> <resources> <colorname="transparent">#9000</color> </resources>
再编写一个styles.xml
<?xmlversion="1.0"encoding="utf-8"?> <resources> <stylename="Transparent"> <itemname="android:windowBackground">@color/transparent</item> <itemname="android:windowIsTranslucent">true</item> <itemname="android:windowAnimationStyle">@+android:style/Animation.Translucent</item> </style> </resources>
最后使用这个style
android:theme="@style/transparent"
参考http://blog.csdn.net/yuejingjiahong/article/details/6668265
8. 对话框风格的Activity
android:theme="@android:style/Theme.Dialog"
9. 运行时切换全屏
/** * 切换全屏和非全屏 */ private void switchFullScreen() { if (null != switchFullScreenToast) { switchFullScreenToast.cancel(); } if (fullScreen) { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); switchFullScreenToast = Toast.makeText(this, R.string.exit_full_screen, Toast.LENGTH_SHORT); switchFullScreenToast.show(); } else { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); switchFullScreenToast = Toast.makeText(this, R.string.enter_full_screen, Toast.LENGTH_SHORT); switchFullScreenToast.show(); } fullScreen = !fullScreen; }
10. 使用自定义style解决自定义title栏高度太小的问题
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="TransparentListView" parent="@android:style/Widget.ListView"> <item name="android:cacheColorHint">@android:color/transparent</item> </style> </resources>
然后使用这个style
<activity android:name=".ui.HomeActivity" android:theme="@style/CmTitleBar"></activity>
发表评论
-
使用Intel HAXM为Android模拟器加速
2013-11-15 17:50 0http://www.tanranran.cn/?p ... -
load bitmap & process bitmap -training系列
2013-11-09 12:11 0http://docs.eoeandroid.com ... -
listview如何高亮显示选中的item
2013-11-03 11:33 0http://stackoverflow.com/qu ... -
ActionBarSharlock配合Navigation Drawer时遇到的小问题
2013-10-27 11:50 0http://stackoverflow.com ... -
Android navi drawer
2013-10-26 21:41 0https://developer.android.c ... -
cache bitmap & display bitmap- training系列
2013-10-26 10:25 0http://developer.android. ... -
博客排版技巧
2013-10-07 18:43 0CnBlogs博文排版技巧 http://www.cnbl ... -
android 传感器之摇一摇
2013-10-07 16:16 0http://blog.csdn.net/xn4545 ... -
android udp广播
2013-10-07 16:14 0http://blog.csdn.net/luzhen ... -
geofence功能
2013-10-07 12:18 0test -
android wifi模块分析
2013-10-04 19:58 0设置、打开wifi热点 http://blog.c ... -
简单试用Android Annotations(2)
2013-10-01 17:15 0一、命名问题 前一篇中提出了一个问题: ... -
简单试用Android Annotations
2013-10-01 11:58 3928参考:试用android annotations ... -
飞鸽协议
2013-09-30 15:13 0http://blog.chinaunix.net/ ... -
zxing二维码
2013-09-30 15:10 0Android之二维码的生成与解析 http://w ... -
android服务发现
2013-09-30 15:06 0不怎么样的博客 upnp研究 http://blog.c ... -
system bin目录下的命令
2013-09-30 13:27 0Android手机WIFI数据开关命令svc教程 h ... -
android jni相关
2013-09-24 14:03 0http://game.ceeger.com/S ... -
service的onStartCommand返回值
2013-09-21 12:16 0http://blog.csdn.net/fr ... -
action bar 2.3
2013-09-20 21:05 0ActionBarSherlock http ...
相关推荐
Android系统提供了多种内置样式,可以通过设置`android:theme`属性来改变Activity的外观。下面列举了一些常用的样式: - `@android:style/Theme.Dialog`:将Activity显示为对话框模式。 - `@android:style/Theme....
requestWindowFeature(Window.FEATURE_NO_TITLE); // 去除标题栏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // 背景变暗 setContentView...
另外,如果仅需将Activity显示为默认的Dialog,可以简化配置,即只需设置`android:theme="@android:style/Theme.Dialog"`或调用`setTheme(android.R.style.Theme_Dialog)`。 ##### 其他创建Dialog的方法 - 使用`...
3. **android:theme属性:** 设置Activity的主题样式,这里使用了系统内置的主题样式`Theme.Black.NoTitleBar.Fullscreen`。 #### 五、设置Activity为Dialog的形式 **知识点概述:** 有时候希望Activity能够以...
少儿编程scratch项目源代码文件案例素材-绝地求生.zip
嵌入式八股文面试题库资料知识宝典-文思创新面试题2010-04-08.zip
一种基于剪切波和特征信息检测的太阳斑点图融合算法.pdf
内容概要:本文详细介绍了并联型有源电力滤波器(APF)在Matlab/Simulink环境下的仿真研究。主要内容涵盖三个关键技术点:一是dq与αβ坐标系下的谐波和无功检测,利用dq变换和FBD技术实现实时检测;二是两相旋转坐标系(dq)与两相静止坐标系(αβ)下的PI控制,通过调整比例和积分环节实现精准控制;三是SVPWM调制方式的应用,通过优化开关时序提升系统效率和性能。文中还提供了详细的仿真介绍文档,包括模型搭建、参数设定以及结果分析。 适合人群:从事电力电子、自动化控制领域的研究人员和技术人员,尤其是对电力滤波器仿真感兴趣的读者。 使用场景及目标:适用于需要深入了解并联型APF工作原理和实现方式的研究人员,旨在通过仿真工具掌握谐波和无功检测、PI控制及SVPWM调制的具体应用。 其他说明:本文不仅提供了理论知识,还结合了实际操作步骤,使读者能够通过仿真模型加深对APF的理解。
Arduino KEY实验例程,开发板:正点原子EPS32S3,本人主页有详细实验说明可供参考。
嵌入式八股文面试题库资料知识宝典-嵌入式C语言面试题汇总(66页带答案).zip
.archivetempdebug.zip
嵌入式系统开发_CH551单片机_USB_HID复合设备模拟_基于CH551单片机的USB键盘鼠标复合设备模拟器项目_用于通过CH551微控制器模拟USB键盘和鼠标输入设备_实现硬
少儿编程scratch项目源代码文件案例素材-剑客冲刺.zip
少儿编程scratch项目源代码文件案例素材-火影.zip
内容概要:本文详细介绍了两极式单相光伏并网系统的组成及其仿真优化方法。前级采用Boost电路结合扰动观察法(P&O)进行最大功率点跟踪(MPPT),将光伏板输出电压提升至并网所需水平;后级利用全桥逆变加L型滤波以及电压外环电流内环控制,确保并网电流与电网电压同频同相,实现高效稳定的并网传输。文中还提供了具体的仿真技巧,如开关频率设置、L滤波参数计算和并网瞬间软启动等,最终实现了98.2%的系统效率和低于0.39%的总谐波失真率(THD)。 适合人群:从事光伏并网系统研究、设计和开发的技术人员,特别是对Boost电路、MPPT算法、逆变技术和双环控制系统感兴趣的工程师。 使用场景及目标:适用于希望深入了解两极式单相光伏并网系统的工作原理和技术细节的研究人员和工程师。目标是在实际项目中应用这些理论和技术,提高光伏并网系统的效率和稳定性。 其他说明:文中提供的仿真技巧和伪代码有助于读者更好地理解和实现相关算法,在实践中不断优化系统性能。同时,注意电网电压跌落时快速切换到孤岛模式的需求,确保系统的安全性和可靠性。
矢量边界,行政区域边界,精确到乡镇街道,可直接导入arcgis使用
嵌入式八股文面试题库资料知识宝典-嵌入式c面试.zip
嵌入式八股文面试题库资料知识宝典-I2C总线.zip
内容概要:本文详细介绍了三种注浆模型——随机裂隙网络注浆模型、基于两相达西定律的注浆模型、基于层流和水平集的注浆扩散模型。首先,随机裂隙网络注浆模型基于地质学原理,模拟裂隙网络发育的实际地质情况,在不同注浆压力下进行注浆作业,以增强地基稳定性和提高承载能力。其次,基于两相达西定律的注浆模型利用数学公式模拟裂隙网络中的流体输送过程,适用于裂隙网络地质条件下的注浆效果分析。最后,基于层流和水平集的注浆扩散模型通过引入层流特性和水平集方法,更准确地模拟注浆过程中的扩散过程。文中还讨论了不同注浆压力对注浆效果的影响,并提出了优化建议。 适合人群:从事岩土工程、地基加固等相关领域的工程师和技术人员。 使用场景及目标:①帮助工程师选择合适的注浆模型和注浆压力;②为实际工程项目提供理论支持和技术指导;③提升地基加固的效果和效率。 其他说明:文章强调了在实际应用中需要结合地质条件、裂隙网络特点等因素进行综合分析,以达到最佳注浆效果。同时,鼓励不断创新注浆工艺和方法,以满足日益增长的地基加固需求。
内容概要:本文详细比较了COMSOL Multiphysics软件5.5和6.0版本在模拟Ar棒板粗通道流注放电现象方面的异同。重点探讨了不同版本在处理电子密度、电子温度、电场强度以及三维视图等方面的优缺点。文中不仅介绍了各版本特有的操作方式和技术特点,还提供了具体的代码实例来展示如何进行精确的仿真设置。此外,文章还讨论了网格划分、三维数据提取和电场强度后处理等方面的技术难点及其解决方案。 适合人群:从事等离子体物理研究的专业人士,尤其是熟悉COMSOL Multiphysics软件并希望深入了解其最新特性的研究人员。 使用场景及目标:帮助用户选择合适的COMSOL版本进行高效、精确的等离子体仿真研究,特别是在处理复杂的Ar棒板粗通道流注放电现象时提供指导。 其他说明:文章强调了在实际应用中,选择COMSOL版本不仅要考虑便捷性和视觉效果,还需兼顾仿真精度和可控性。