Android中应用界面主题Theme使用方法和页面定时跳转应用
时间:2023-08-30 17:05:59
主题Theme就是用来设置界面UI风格,可以设置整个应用或者某个活动Activity的界面风格。在Android SDK中内置了下面的Theme,可以按标题栏Title Bar和状态栏Status Bar是否可见来分类:
android:theme="@android:style/Theme.Dialog" 将一个Activity显示为能话框模式
android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不显示应用程序标题栏,并全屏
android:theme="Theme.Light" 背景为白色
android:theme="Theme.Light.NoTitleBar" 白色背景并无标题栏
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景并无标题栏
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏
android:theme="Theme.Wallpaper" 用系统桌面为应用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,且无标题栏
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏
android:theme="Translucent" 半透明
android:theme="Theme.Translucent.NoTitleBar" 半透明、无标题栏
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、无标题栏、全屏
android:theme="Theme.Panel"
android:theme="Theme.Light.Panel"
android:theme="@android:style/Theme.Dialog" 将一个Activity显示为能话框模式
android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不显示应用程序标题栏,并全屏
android:theme="Theme.Light" 背景为白色
android:theme="Theme.Light.NoTitleBar" 白色背景并无标题栏
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景并无标题栏
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏
android:theme="Theme.Wallpaper" 用系统桌面为应用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,且无标题栏
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏
android:theme="Translucent" 半透明
android:theme="Theme.Translucent.NoTitleBar" 半透明、无标题栏
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、无标题栏、全屏
android:theme="Theme.Panel"
android:theme="Theme.Light.Panel"
这些主题可以应用到整个应用Application范围或者某个活动Activity范围中。
应用Application范围
在AndroidManifest.xml中的application节点中设置theme属性,主题theme应用到整个应用程序中。
<application
Android:icon=”@drawable/icon”
Android:icon=”@string/app_name”
Android:icon=”@android:style/ Theme.Black.NoTitleBar”>
活动Activity范围
使用java代码或者在AndroidManifest.xml中对活动Activity的主题进行设置,主题仅应用到当前活动中。
在AndroidMainifest.xml设置方法:
<activity
android:name=“.About”
android:label=“@string/app_name”
android:theme=“@android:style/ Theme.Black.NoTitleBar” >
使用java代码进行设置,在当前活动Activity的onCreate中进行设置:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.main);
}
-------------跳转---------------------
public void Start() {
new Thread() {
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Intent intent = new Intent();
intent.setClass(WelComeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}.start();
}
---------为按钮添按下效果-----------
imageButton1 = (ImageButton) findViewById(R.id.imageButton3);
imageButton1.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// 更改为按下时的背景图片
v.setBackgroundResource(R.drawable.menu_btn_f);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
// 改为抬起时的图片
v.setBackgroundResource(R.drawable.menu_btn);
}
return false;
}
});
标签:主题,Theme,定时跳转
0
投稿
猜你喜欢
C# DataSet查看返回结果集的实现
2021-10-10 09:54:31
基于Spring中各个jar包的作用及依赖(详解)
2023-05-06 04:08:47
java字符串常用操作方法(查找、截取、分割)
2023-11-29 03:21:13
Android开发实现的IntentUtil跳转多功能工具类【包含视频、音频、图片、摄像头等操作功能】
2023-05-27 23:58:01
spring boot 加载web容器tomcat流程源码分析
2021-12-05 14:48:38
c# 将Minio.exe注册成windows服务
2022-09-25 20:51:18
自定义Android注解系列教程之注解变量
2022-10-17 05:42:10
Java加载资源文件时的路径问题的解决办法
2023-05-09 23:22:40
如何实现java Iterator迭代器功能
2023-10-14 14:30:49
Android仿微信对话列表滑动删除效果
2023-04-15 13:22:30
Java抽象类的概念讲解
2023-11-04 13:40:35
Java集合系列之ArrayList源码分析
2023-01-31 03:02:36
C#中?、?.、??、??=运算符的用法
2022-11-10 18:11:51
Android 采用AOP方式封装6.0权限管理的方法
2022-09-15 23:26:49
执行java请求时导致在脚本执行结束时JVM无法退出
2023-11-25 05:57:13
详解Maven多模块打包遇到的问题解决方法
2022-12-25 13:01:12
android教程之使用popupwindow创建菜单示例
2023-01-24 22:08:10
Java Vector和ArrayList的异同分析及实例讲解
2023-12-03 17:27:10
C# List引用类型克隆的3种方法
2023-04-19 14:20:44
深入C#中get与set的详解
2022-05-29 21:04:10