‘壹’ 如何在android中实现全屏,去掉标题栏效果
方法:在布局文件的预览界面,如下图操作
这样就成功去除了标题栏。
‘贰’ android怎么修改系统dialog风格
1、编写一个文本样式。
DIALOG的标题是一个textview,在sytles.xml中,添加如下代码来设置你自己的文本样式:
?
<style name="DialogWindowTitle">
<item name="android:textSize">22sp</item>
<item name="android:textColor">@color/font_dark_grey</item>
</style>
2、设置对话框的标题主题。
上面的标题文本并不能直接设置为对话框的标题样式。 我们还需要编写一个表示标题的主题的style,在这里指定标题的文本样式。代码如下:
?
<style name="DialogWindowTitle.DeviceDefault">
<item name="android:maxLines">1</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:textAppearance">@style/DialogWindowTitle</item>
</style>
3、设置对话框主题。
接下来,我们编写我们的对话框主题,在这里指定标题的主题。由于一些属性并不是public的,所以我们需要继承自原来的某个style,代码如下:
?
<!--Dialog主题-->
<style name="Theme.DeviceDefault.Dialog" parent="@android:style/Theme.DeviceDefault.Light.Dialog">
<item name="android:windowTitleStyle">@style/DialogWindowTitle.DeviceDefault</item>
</style>
4、自定义App的主题。
接下来,我们需要在我们的App theme中指定我们的对话框使用这种主题,所以需要定义一个App theme。同样由于App theme的许多属性并不是public的(比如下面要提到的标题下面的那条蓝线),所以我们要继承自一个原生的style。这里我根据程序需要选择了Theme.Holo.Light.NoActionBar,代码如下:
?
<style name="ParkingTheme" parent="@android:style/Theme.Holo.Light.NoActionBar">
<item name="android:dialogTheme">@style/Theme.DeviceDefault.Dialog</item>
</style>
5、指定App主题。
最后一步,我们需要在AndroidManifest.xml文件中,指定我们的app主题。这步很简单,只需要在application标签中指定android:theme的值即可,如下:
?
android:theme="@style/ParkingTheme"
不过这只是指定了Dialog的主题。如果是通过AlertDialog创建出来的对话框,主题还是原来的。所以我们还需要以下步骤。
7、编写AlertDialog主题。
我们无法直接继承系统主题里的AlertDialog的style。如把parent指定为Theme.DeviceDefault.Dialog.Alert,Theme.Holo.Dialog.Alert,Theme.DeviceDefault.Light.Dialog.Alert或Theme.Holo.Light.Dialog.Alert,都会导致编译不过。所以我们需要继承自Dialog的style。在这里我以Theme.Holo.Light.Dialog为例,代码如下:
<!--AlderDialog主题-->
<style name="Theme.DeviceDefault.Dialog.Alert" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowTitleStyle">@style/DialogWindowTitle.DeviceDefault</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
</style>
在这里我参考了原生的alertDialog的style,设定了窗口背景为透明,以及windowContentOverlay为null这两个重要属性,否则你会看到在AlertDialog下面还有一层对话框的背景,或者是对话框的背景遮住了所有内容这样的问题存在。
8、指定AlertDialog的主题。
我们需要在第4步所说的自定义的AppTheme中,添加一行代码来指定要使用的AlertDialog的style,代码如下:
?
<item name="android:alertDialogTheme">@style/Theme.DeviceDefault.Dialog.Alert</item>
9、修改标题下面的蓝色线。
如果你修改了对话框的主题颜色,那么标题下面的蓝色的线肯定会让你很郁闷。如果对话框较少,你可以选择隐藏标题,然后自定义一个包含了标题的View来设置为对话框的内容。但是如果你的对话框有许多种,而且本来都是可以调用原来的API就来生成的话,要去定义这么多个带标题的view,这样做下来心里肯定是很纠结的。
标题下面的蓝色的线,并不是在Dialog或AlertDialog中设置或通过它们的style中定义的。它是定义在各种风格的dialog的layout当中,然后再在AppTheme里面指定dialog的对应属性。遗憾的是,目前我看到这几个相关属性还不是public的,不能自己设置,所以只有通过Java代码来实现了。
表示这条蓝色的线的叫做titleDivider,我们可以通过getResources()的API来获取它的IP,然后设置颜色。代码如下:
?
public static final void dialogTitleLineColor(Dialog dialog, int color) {
Context context = dialog.getContext();
int divierId = context.getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = dialog.findViewById(divierId);
divider.setBackgroundColor(color);
‘叁’ android加载自定义dialog,背景总是黑色的.不知道为什么.求解答
AlertDialog.Builder builder = new AlertDialog.Builder(UserInformationActivity.this,AlertDialog.THEME_HOLO_LIGHT);这种形式的,其中“AlertDialog.THEME_HOLO_LIGHT”设置背景,这个是白色的
把Activity设置成dialog的,修改AndroidManifest.xml中该Activity的theme,如:android:theme="@android:style/Theme.Holo.Light.Dialog.NoActionBar" ,这样这个Activity会以dialog的形式弹出,并且是白色的
自己写一个自定义dialog继承dialog,你dialog的布局文件的最外层layout背景颜色设置成白色的
‘肆’ Actionbar 可不可以把标题栏隐藏掉
Actionbar 可以把标题栏隐藏。
在Android3.0之后,Google对UI导航设计上进行了一系列的改革,其中有一个非常好用的新功能就是引入的ActionBar,他用于取代3.0之前的标题栏,并提供更为丰富的导航效果。
一、添加ActionBar
1、不需要导入ActionBar,因为在android3.0或者以上版本中,ActionBar已经默认的包含在Activity中
2、在Android3.0的默认主题“holographic”中,已经创造了ActionBar
3、当android:minSdkVersion 或者 android:targetSdkVersion 属性被设置成11或者更高时,应用会被认为是Android3.0版本(默认含有ActionBar)
二、隐藏ActionBar
1、可以通过把主题设置为Theme.Holo.NoActionBar为一个Activity去除掉ActionBar。<activity android:theme="@android:style/Theme.Holo.NoActionBar">
2、也可以通过在代码中调用show()或者hide()方法来相应的显示或者隐藏ActionBar
3、在使用actionBar.hide();方法是系统默认会将ActionBar占用的空间分配给界面,此时显示的界面将会重新绘制。同样调用actionBar.show();时也会重新绘制界面。如果一个程序需要频繁的显示或者隐藏ActionBar的话,这样就不会有良好的效果。Google提供给一个属性可以让ActionBar浮在界面上,当然你可以让ActionBar的背景为透明,这样会有良好的体验效果。
‘伍’ Android系统自带样式Theme总结
本文从网上复制,给自己做笔记的,摘自: http://blog.csdn.net/hongya1109110121/article/details/11985545
Android系统自带样式(@android:style/) (转)
1 android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
布局页面最上面 不会显示 android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。
2 android:theme="@style/AppTheme"
布局页面最上面 显示 android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。
其他
在AndroidManifest.xml文件的activity中配置
1、android:theme="@android:style/Theme"
默认状态,即如果theme这里不填任何属性的时候,默认为Theme
2、android:theme="@android:style/Theme.NoDisplay"
任何都不显示。比较适用于只是运行了activity,但未显示任何东西
3、android:theme="@android:style/Theme.NoTitleBar“
背景主题的没有标题栏的样式,默认如果没有设置的话,显示黑背景
4、android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
背景主题的没有标题栏且全屏的样式,默认为黑背景
5、android:theme="@android:style/Theme.Black"
默认状态下黑背景
6、android:theme="@android:style/Theme.Black.NoTitleBar"
黑背景主题的没有标题栏的样式
7、android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
黑背景主题的没有标题栏且全屏的样式
8、android:theme="@android:style/Theme.Light"
默认状态下亮背景,与上述黑背景Theme.Black相反
9、android:theme="@android:style/Theme.Light.NoTitleBar"
亮背景主题的没有标题栏的样式,与Theme.Black.NoTitleBar相反
10、android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
亮背景主题的没有标题栏且全屏显示的样式,与Theme.Black.NoTitleBa.Fullscreenr相反
11、android:theme="@android:style/Theme.Dialog"
对话框样式 将整个activity变成对话框样式出现
12、android:theme="@android:style/Theme.InputMethod"
Window animations that are applied to input method overlay windows
13、android:theme="@android:style/ Theme.Panel"
删除掉所有多余的窗口装饰,在一个空的矩形框中填充内容,作用范围相当于把dialog中的所有元素全部去掉,只是一个空的矩形框,且此为默认的样式
14、android:theme="@android:style/ Theme.Light.Panel"
删除掉所有多余的窗口装饰,在一个空的矩形框中填充内容,作用范围相当于把dialog中的所有元素全部去掉,只是一个空的矩形框,且默认是light的样式
15、android:theme="@android:style/Theme.Wallpaper"
使用墙纸做主题,默认状态。
16、android:theme="@android:style/ Theme.WallpaperSettings"
使用墙纸做主题,默认是使用将上一个界面调暗之后作为主题
17、android:theme="@android:style/ Theme.Light.WallpaperSettings"
使用墙纸做主题,默认Light状态
18、android:theme="@android:style/Theme.Wallpaper.NoTitleBar"
使用墙纸做主题,且没有标题栏
19、android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
使用墙纸做主题,且没有标题栏,且全屏显示
20、android:theme="@android:style/Theme.Translucent"
半透明状态下的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。
21、android:theme="@android:style/Theme.Translucent.NoTitleBar"
半透明状态下没有标题栏的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。
22、android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
半透明状态下没有标题栏且全屏的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。
摘自: http://blog.csdn.net/hongya1109110121/article/details/11985545
‘陆’ Android WebView加载页面的输入框被软键盘遮挡的问题
当实现沉浸式状态栏时遇到软件盘遮挡WebView页面的输入框的问题,这是实现方式有问题,应该检查你的实现方式。
1)加载WebView的Activty不能设置为全屏模式,即Theme.NoTitleBar.Fullscreen,可以使用Theme.Holo.Light.NoActionBar
2)沉浸式状态栏的实现方式,在Activity的根布局里加两个属性:
android:clipToPadding="true" 设置你的绘制区域在padding里面
android:fitsSystemWindows="true" 调整view的padding属性为系统窗口 留出空间
在Activity的onCreate方法里面设置标题栏为透明,即:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_ST ATUS);
3)Activity里面不能设置android:windowSoftInputMode的属性,使用默认的属性即可
以上3步即可实现沉浸式状态栏并且能保证你的WebView加载的HTML页面的输入框不被软键盘遮挡。
顶
0
踩
0
上一篇 Android Studio在SVN上创建分支
下一篇 Android Converty问题解决方案
相关文章推荐
• android中webview加载html输入框不能输入内容问题记录
• 如何解决Android软键盘盖住输入框的问题
• Android 软键盘盖住输入框的问题
• Android 软键盘盖住输入框的问题
• Android 软键盘盖住输入框的问题
• Android 软键盘盖住输入框的问题
• Android 软键盘盖住输入框的问题
• android popupwindow 中输入框被软键盘弹出挡住问题解决
• ios解决软键盘遮挡输入框问题
• Android软键盘遮挡输入框解决方法
参考知识库
Android知识库
34080 关注 | 2937 收录
猜你在找
Android中的五大布局
零基础学软件之HTML语言
【Android APP开发】Android高级商业布局快速实现
html5的app开发
Android前沿技术—《软件框架搭建》
Android移植基础
html系统学习篇
零基础学习HTML5—html+css基础
Android开发之初窥门径
Android之数据存储
关闭