导航:首页 > 操作系统 > android设置标题栏背景

android设置标题栏背景

发布时间:2025-01-01 17:13:50

A. android怎么用基类控制标题栏

[html] view plain
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_titlebar"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#ed4255" >

<TextView
android:id="@+id/text_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="marquee"
android:gravity="center_horizontal|center"
android:singleLine="true"
android:text="标题栏"
android:textColor="#ffffffff"
android:textSize="20dp" />

<TextView
android:id="@+id/button_backward"
android:layout_width="60dp"
android:layout_height="match_parent"
android:drawableLeft="@drawable/back_arrow"
android:drawablePadding="6dp"
android:ellipsize="end"
android:gravity="center"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="返回"
android:textColor="#ffffffff"
android:textSize="18dp"
android:visibility="invisible" />

<TextView
android:id="@+id/button_forward"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:drawablePadding="6dp"
android:ellipsize="end"
android:gravity="center"
android:paddingLeft="5dp"
android:singleLine="true"
android:text="提交"
android:textColor="#ffffffff"
android:textSize="18dp"
android:visibility="invisible" />

</RelativeLayout>

B. android dialog 怎么设置全屏

theme.notitlebar
:
不显示应�'a8程序标题栏
theme.notitlebar.fullscreen
:
不显示应用程序标题栏,并全屏
theme.light
:背景为白色
theme.light.notitlebar
:
白色背景并无标题栏
theme.light.notitlebar.fullscreen
:
白色背景,无标题栏,全屏
theme.black
:
背景黑色
theme.black.notitlebar
:
黑色背景并无标题栏
theme.black.notitlebar.fullscreen
:
黑色背景,无标题栏,全屏
theme.wallpaper
:
用系统桌面为应用程序背景
theme.wallpaper.notitlebar
:
用系统桌面为应用程序背景,且无标题栏
theme.wallpaper.notitlebar.fullscreen
:
用系统桌面为应用程序背景,无标题栏,全屏
theme.translucent
:
透明背景

C. 怎么自定义Android标题栏修改TitleBar的布局

Android程序默认的Activity标题栏只能显示一段文字,而且不能改变它的布局、颜色、标题栏的高度等。如果想要在标题栏加上个图标、button、输入框、进度条、修改标题栏颜色等,只能使用自定义的标题栏。自定义标题栏可以通过在onCreate函数中添加以下代码来实现,需要注意的是代码的顺序必须按照下面的样式,否则将无效。
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.mainactivity); //Activity的布局
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.titlebar); //标题栏的布局
虽然上面这样可以在标题栏加入一些控件,但是仍然不能改变标题栏的高度、背景色,要想达到这个目的,只能使用theme(主题)。因此往project里先添加一个style。改变背景色修改android:windowTitleBackgroundStyle的值,改变标题栏高度则修改android:windowTitleSize的值。下面是一个示例:






接着再修改AndroidManifest.xml文件,找到要自定义标题栏的Activity,添加上android:theme值,比如:

Java代码
android:theme值就是上面那个style.xml文件里定义的一个style的name值。

按照以上的步骤,修改标题栏布局、高度、背景色的功能就实现了。

阅读全文

与android设置标题栏背景相关的资料

热点内容
手机文件夹应用推荐怎么关 浏览:605
服务器为什么要分业务口和管理口 浏览:682
杨辉三角java算法 浏览:55
cmd编译错误找不到符号 浏览:695
linuxip机器名 浏览:487
服务器喇叭和频道喇叭有什么区别 浏览:31
闲鱼排名算法如何计算 浏览:975
linuxtargz解压命令 浏览:741
还完房贷后解压手续银行会代办吗 浏览:811
解压烹饪乐高 浏览:675
元神的服务器怎么看 浏览:362
stc8单片机串口中断 浏览:954
信号分析pdf 浏览:927
暴力删除命令 浏览:803
qt如何编译加快速度 浏览:903
php添加数据sql语句 浏览:717
免费的小说app有什么 浏览:405
螺杆压缩机进气阀动画 浏览:651
两台服务器如何做负载均衡 浏览:227
程序员的工资是涨的吗 浏览:813