导航:首页 > 操作系统 > 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设置标题栏背景相关的资料

热点内容
32岁女程序员迷茫 浏览:47
红米无法访问data文件夹 浏览:685
国家反诈中心app为什么审核不过去 浏览:871
linuxwindows启动盘 浏览:811
百度贴吧app怎么看访客 浏览:435
javaio文件复制 浏览:407
app上海总部在什么楼里 浏览:371
格式化硬盘dos命令 浏览:496
红茶可以缓解压力 浏览:999
腾讯云怎么弄七十多一年云服务器 浏览:721
java按钮设置图片 浏览:866
php数字分页代码 浏览:793
旅游业程序员 浏览:403
区块链第三代加密数字资产 浏览:525
把播放清单放在云服务器上 浏览:880
phpppt下载 浏览:302
1929pdf 浏览:366
编译器是终端吗 浏览:541
pdf改b4 浏览:382
命令通道 浏览:712