Android AndroidManifest属性

2023-10-24 23:08

本文主要是介绍Android AndroidManifest属性,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Android平台定义的主题样式:

android:theme="@android:style/Theme.Dialog"   将一个Activity显示为对话框模式
•android:theme="@android:style/Theme.NoTitleBar"  不显示应用程序标题栏
•android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  不显示应用程序标题栏,并全屏
•android:theme="@android:style/Theme.Light"  背景为白色
•android:theme="@android:style/Theme.Light.NoTitleBar"  白色背景并无标题栏
•android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"  白色背景,无标题栏,全屏
•android:theme="@android:style/Theme.Black"  背景黑色
•android:theme="@android:style/Theme.Black.NoTitleBar"  黑色背景并无标题栏
•android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"    黑色背景,无标题栏,全屏
•android:theme="@android:style/Theme.Wallpaper"  用系统桌面为应用程序背景
•android:theme="@android:style/Theme.Wallpaper.NoTitleBar"  用系统桌面为应用程序背景,且无标题栏
•android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"  用系统桌面为应用程序背景,无标题栏,全屏
•android:theme="@android:style/Translucent" 半透明效果
•android:theme="@android:style/Theme.Translucent.NoTitleBar"  半透明并无标题栏
•android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"  半透明效果,无标题栏,全屏
•android:theme="@android:style/Theme.Panel"

Android平台定义了三种字体大小:

"?android:attr/textAppearanceLarge"
"?android:attr/textAppearanceMedium"
"?android:attr/textAppearanceSmall"

Android字体颜色:

android:textColor="?android:attr/textColorPrimary"
android:textColor="?android:attr/textColorSecondary"
android:textColor="?android:attr/textColorTertiary"
android:textColor="?android:attr/textColorPrimaryInverse"
android:textColor="?android:attr/textColorSecondaryInverse"

Android的ProgressBar样式:

style="?android:attr/progressBarStyleHorizontal"
style="?android:attr/progressBarStyleLarge"
style="?android:attr/progressBarStyleSmall"
style="?android:attr/progressBarStyleSmallTitle"

分隔符

横向: <View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
纵向: <View android:layout_width="1dip"
android:layout_height="fill_parent"
android:background="?android:attr/listDivider" /

CheckBox样式  

style="?android:attr/starStyle"


类似标题栏效果的TextView
style="?android:attr/listSeparatorTextViewStyle"

其它有用的样式
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingRight="?android:attr/scrollbarSize"
style="?android:attr/windowTitleBackgroundStyle"
style="?android:attr/windowTitleStyle"
android:layout_height="?android:attr/windowTitleSize"
android:background="?android:attr/windowBackground"

 

修改Activity的标题栏样式

如在styles.xml中增加
<resources> 
   
 <style name="AutoWindowTitleBackground"> 
       
 <item name="android:background">#778899</item> 
   
 </style> 
   
 <style name="autoWindowTitlebar" parent="android:Theme"> 
       
 <item name="android:windowTitleSize">32dp</item>
        <item name="android:windowTitleBackgroundStyle">@style/
AutoWindowTitleBackground</item>
   
 </style> 
</resources>
接着再修改AndroidManifest.xml文件,找到要自定义标题栏的Activity,添加上android:theme值,比如:
<activity android:name=".MainActivity" android:theme="@style/autoWindowTitlebar">

 

去掉所有Activity界面的标题栏
修改AndroidManifest.xml

在application 标签中添加android:theme=”@android:style/Theme.NoTitleBar”

 

 

 

 

Android默认情况下提供了一些实用的主题样式,比如说Theme.Dialog可以让你的Activity变成一个窗口风格,而Theme.Light则让你的整个Activity具有白色的背景,而不是黑色那么沉闷。具体使用方法很简单在Androidmanifest.xml文件中对你的Activity节点上加入些代码,如图1所示:
越来越多互联网企业都在Android平台上部署其客户端,为了提升用户体验,这些客户端都做得布局合理而且美观.......Android的Style设计就是提升用户体验的关键之一。Android上的Style分为了两个方面:
1,Theme是针对窗体级别的,改变窗体样式;
2,Style是针对窗体元素级别的,改变指定控件或者Layout的样式。

Android系统的themes.xml和style.xml(位于系统源代码frameworks\base\core\res\res\values\)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。
标签: Android SDK

代码片段(5)

[图片] tu1.jpg

[图片] 效果图.gif

[代码] themes.xml

01 <!-- Window attributes -->   
02 <item name="windowBackground">@android:drawable/screen_background_dark</item>   
03 <item name="windowFrame">@null</item>   
04 <item name="windowNoTitle">false</item>   
05 <item name="windowFullscreen">false</item>   
06 <item name="windowIsFloating">false</item>   
07 <item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>   
08 <item name="windowTitleStyle">@android:style/WindowTitle</item>   
09 <item name="windowTitleSize">25dip</item>   
10 <itemname="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>   
11 <itemname="android:windowAnimationStyle">@android:style/Animation.Activity</item>

[代码] styles.xml

01 <?xml version="1.0" encoding="UTF-8"?>
02 <resources>
03  <style name="TextView">
04   <item name="android:textSize">18sp</item>
05   <item name="android:textColor">#008</item>
06   <item name="android:shadowColor">@android:color/black</item>
07   <item name="android:shadowRadius">2.0</item>
08  </style>
09     
10  <style name="EditText">
11   <item name="android:shadowColor">@android:color/black</item>
12   <item name="android:shadowRadius">1.0</item>
13   <item name="android:background">@android:drawable/btn_default</item>
14   <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
15  </style>
16     
17     <style name="Button">
18         <item name="android:background">@android:drawable/edit_text</item>
19         <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
20     </style>
21 </resources>

[代码] main.xml

01 <?xml version="1.0" encoding="utf-8"?>  
02 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
03     android:orientation="vertical" android:layout_width="fill_parent"  
04     android:layout_height="fill_parent">  
05     <TextView android:layout_width="fill_parent"  
06         android:layout_height="wrap_content" android:text="@string/hello"  
07         style="@style/TextView" />  
08     <EditText android:id="@+id/EditText01"android:layout_height="wrap_content"  
09         style="@style/EditText" android:layout_width="fill_parent"  
10         android:text="类似Button的EditText"></EditText>  
11     <EditText android:id="@+id/EditText02"android:layout_height="wrap_content"  
12         android:layout_width="fill_parent" android:text="普通的EditText"></EditText>  
13     <Button android:id="@+id/Button01" android:layout_height="wrap_content"  
14         style="@style/Button" android:layout_width="fill_parent"android:text="类似EditText的Button"></Button>  
15 </LinearLayout>

 

 

 

这篇关于Android AndroidManifest属性的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/278376

相关文章

Android Mainline基础简介

《AndroidMainline基础简介》AndroidMainline是通过模块化更新Android核心组件的框架,可能提高安全性,本文给大家介绍AndroidMainline基础简介,感兴趣的朋... 目录关键要点什么是 android Mainline?Android Mainline 的工作原理关键

如何解决idea的Module:‘:app‘platform‘android-32‘not found.问题

《如何解决idea的Module:‘:app‘platform‘android-32‘notfound.问题》:本文主要介绍如何解决idea的Module:‘:app‘platform‘andr... 目录idea的Module:‘:app‘pwww.chinasem.cnlatform‘android-32

Android实现打开本地pdf文件的两种方式

《Android实现打开本地pdf文件的两种方式》在现代应用中,PDF格式因其跨平台、稳定性好、展示内容一致等特点,在Android平台上,如何高效地打开本地PDF文件,不仅关系到用户体验,也直接影响... 目录一、项目概述二、相关知识2.1 PDF文件基本概述2.2 android 文件访问与存储权限2.

Android Studio 配置国内镜像源的实现步骤

《AndroidStudio配置国内镜像源的实现步骤》本文主要介绍了AndroidStudio配置国内镜像源的实现步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、修改 hosts,解决 SDK 下载失败的问题二、修改 gradle 地址,解决 gradle

在Android平台上实现消息推送功能

《在Android平台上实现消息推送功能》随着移动互联网应用的飞速发展,消息推送已成为移动应用中不可或缺的功能,在Android平台上,实现消息推送涉及到服务端的消息发送、客户端的消息接收、通知渠道(... 目录一、项目概述二、相关知识介绍2.1 消息推送的基本原理2.2 Firebase Cloud Me

Spring Security基于数据库的ABAC属性权限模型实战开发教程

《SpringSecurity基于数据库的ABAC属性权限模型实战开发教程》:本文主要介绍SpringSecurity基于数据库的ABAC属性权限模型实战开发教程,本文给大家介绍的非常详细,对大... 目录1. 前言2. 权限决策依据RBACABAC综合对比3. 数据库表结构说明4. 实战开始5. MyBA

CSS will-change 属性示例详解

《CSSwill-change属性示例详解》will-change是一个CSS属性,用于告诉浏览器某个元素在未来可能会发生哪些变化,本文给大家介绍CSSwill-change属性详解,感... will-change 是一个 css 属性,用于告诉浏览器某个元素在未来可能会发生哪些变化。这可以帮助浏览器优化

Android中Dialog的使用详解

《Android中Dialog的使用详解》Dialog(对话框)是Android中常用的UI组件,用于临时显示重要信息或获取用户输入,本文给大家介绍Android中Dialog的使用,感兴趣的朋友一起... 目录android中Dialog的使用详解1. 基本Dialog类型1.1 AlertDialog(

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

Android自定义Scrollbar的两种实现方式

《Android自定义Scrollbar的两种实现方式》本文介绍两种实现自定义滚动条的方法,分别通过ItemDecoration方案和独立View方案实现滚动条定制化,文章通过代码示例讲解的非常详细,... 目录方案一:ItemDecoration实现(推荐用于RecyclerView)实现原理完整代码实现