android 透明变成白色,android – 状态栏不透明但是白色

为了用anko DSL测试kotlin我决定在最后一个

android studio ide(2.1.3)中使用kotlin插件(1.0.3)和最新的anko库(0.9)开始一个新的proyect

我使用默认的proyect Navigation Drawer Activity,所以我只需要将主xml转换为anko.

这是xml:

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/drawer_layout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"

tools:openDrawer="start">

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:layout_height="wrap_content"

android:layout_width="match_parent"

android:theme="@style/AppTheme.AppBarOverlay">

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary"

app:popupTheme="@style/AppTheme.PopupOverlay" />

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

android:paddingBottom="@dimen/activity_vertical_margin"

app:layout_behavior="@string/appbar_scrolling_view_behavior" >

android:text="Hello World!"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

android:id="@+id/nav_view"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_gravity="start"

android:fitsSystemWindows="true"

app:headerLayout="@layout/nav_header_main"

app:menu="@menu/activity_main_drawer" />

正如你在这里看到的那样,它工作得很好:

13db037ddaa024c0b36d98fd58388061.png

使用anko,我尝试从xml复制每个细节,获取此代码:

class MainActivityUi: AnkoComponent {

override fun createView(ui: AnkoContext) = with(ui) {

drawerLayout {

id = R.id.drawer_layout

fitsSystemWindows = true

coordinatorLayout {

appBarLayout(R.style.AppTheme_AppBarOverlay) {

toolbar {

id = R.id.toolbar

backgroundColor = colorAttr(R.attr.colorPrimary)

popupTheme = R.style.AppTheme_PopupOverlay

}.lparams(height=dimenAttr(R.attr.actionBarSize),width=matchParent)

}.lparams(width=matchParent)

relativeLayout {

padding = dip(16)

textView("Hello World!")

}.lparams(height=matchParent,width=matchParent) {

behavior = AppBarLayout.ScrollingViewBehavior()

}

}.lparams(height=matchParent,width=matchParent)

navigationView {

id = R.id.nav_view

inflateHeaderView(R.layout.nav_header_main)

inflateMenu(R.menu.activity_main_drawer)

}.lparams(height=matchParent) {

gravity = Gravity.START

fitsSystemWindows = true

}

}

}

}

相反,我得到了这个白色状态栏:sKWfb.png

我做的唯一更改是在MainActivity中将setContentView(R.layout.activity_main)更改为MainActivityUi.setContentView(this).

所以,我的问题是,当它们是相同的视图和布局时,为什么会发生这种情况?我该如何解决这个问题?

编辑:我正在使用在Android Studio中创建的默认项目,您选择新的项目,然后选择DrawerNavigationActivity.如果在setContentView中我选择显示xml的视图,状态栏是蓝色的(第一个屏幕截图),但如果我选择显示anko的视图,我会得到白色状态栏.

在这两种情况下,我使用相同的主题,颜色等,当使用xml布局时,一切都运行完美,所以它必须是一个anko的问题

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

操作系统上机作业--实现shell(1)(多进程)

sh1.c: 实现shell程序,要求具备如下功能支持命令参数 $ echo arg1 arg2 arg3 $ ls /bin /usr/bin /home 实现内置命令cd、pwd、exit $ cd /bin $ pwd /bin 实现思路:在获取命令字符串后,用strtok函数对字符串进行处理,获取参数…

VC下勉强可用的list

linux内核中的list太好用了,可惜VC编译器不支持 typeof 关键字,将linux内核中的list直接移植过来不能用 修改所有与typeof相关的代码后,终于可以勉强在VC下运行起来了,但是还不完美,list_for_each_entry和list_for_eac…

当执行游戏0xc000007b错误的解决方法

如图,这个错误使无数玩家烦恼。 出现这个错误,可能是硬件的问题,也可能是软件的问题。可是,因为硬件引起该问题的概率非常小,而且除了更换硬件之外没有更好的解决方法,因此本文将具体介绍怎样通过软件解决此…

android触屏音文件地址,Android音视频-音频采集

Android的音视频开发是我暂定的一个职业发展的一个方向,通过自学记录一些记了又忘记的知识。音频基础知识采样率(samplerate)蓝色代表模拟音频信号,红色的点代表采样得到的量化数值。采用就是把模拟信号数字化的过程,不仅仅是音频需要采样&am…

平衡二叉树,AVL树之图解篇

学习过了二叉查找树,想必大家有遇到一个问题。例如,将一个数组{1,2,3,4}依次插入树的时候,形成了图1的情况。有建立树与没建立树对于数据的增删查改已经没有了任何帮助,反而增添了维护的成本。而只有建立的树如图2,才能…

窗体

GDI:图形设备接口 所有能够将电子信号转换成图像显示的设备是图形设备, 常见的图形设备有显示器,打印机。 Winform封装了GDI底层的接口,提供一组面向对象的接口,供我们使用 Partial关键字,用他修饰的类叫分布类/部分类…

android程序到处apk,导出已安装到手机中程序的apk文件

查看该手机所有安装包的包名,输入adb shell pm list packages找到你要导出的包名获取该安装apk的路径,输入adb shell pm path com.pfoc.myacurite得到包所在路径:导出文件,adb pull /data/app/com.pfoc.myacurite-1/base.apk /Use…

数据结构--顺序栈

栈&#xff1a;限定仅在表尾进行插入或删除操作的线性表&#xff0c;对栈来说&#xff0c;表尾端为栈顶&#xff0c;表头端为栈底。 本文实现了顺序栈的表示和相关函数操作&#xff0c;以及一些验证性代码。 #include<stdio.h> #include<stdlib.h> #include<w…

Mysql 的一些基本用法

一、增加字段 alter table students add IsImportJcxx int set default 0 COMMENT 是否导入基础信息平台 1 是导入; 二、删除字段 alter table provincestudentinfo drop column NativePlace; 三、创建表 CREATE TABLE 表名 ( IconId int not null auto_increment, 字段名 …

Python 文件的输入与输出

1. 文本文件的读写主要通过open()所构建的文件对象来实现。我们打开一个文件&#xff0c;并使用一个对象来表示该文件 , f open(d&#xff0c;r) 其中d是文件名&#xff0c;r是模式 "r" 文件只读,使用 f.write()会报错 "w" 用于写入&#xff0c;每次使用f…

查询表的内容

1&#xff1a;as给表另外命名 2&#xff1a;desc倒序 3&#xff1a;order by分组 4&#xff1a;select*form表名where条件转载于:https://www.cnblogs.com/chen1101465910/p/3719944.html

人之为生也&#xff0c;凡不破者亦难立之。纵所思之&#xff0c;生而顺之者&#xff0c;亦难成也。然吾之路也&#xff0c;亦难行之&#xff0c;至此二十有余&#xff0c;虽无半百之所历&#xff0c;亦无顺途&#xff0c;每及思之&#xff0c;慨之多也。 偶有所感&#xff0c;念…

Delphi 一些函数解释

AdjustWindowRect 给定一种窗口样式&#xff0c;计算获得目标客户区矩形所需的窗口大小 AnyPopup 判断屏幕上是否存在任何弹出式窗口 ArrangeIconicWindows 排列一个父窗口的最小化子窗口 AttachThreadInput 连接线程输入函数 BeginDeferWindowPos 启动构建一系列新窗口位置的过…

盒子模型的总结

转载于:https://www.cnblogs.com/zy2012/p/3725677.html

ubuntu node.js Binaries方式安装(二进制文件安装)

node.js在windows下有安装文件&#xff0c;直接一路下一步就可以了&#xff0c;但大家都知道在windows下用node.js总会遇到一些问题&#xff0c;所以就会用到linux。 看到网上几乎是在linux下编译安装node.js。感觉很奇怪&#xff0c;其实官网直接有 node.js linux binaries文…

maven generating project in batch mode hang

现象&#xff1a; 执行 archetype:generate 的时候&#xff0c;会产生[INFO] Generating project in Batch mode原因是&#xff1a;网速问题&#xff0c; 解决方法&#xff1a; 设置maven不要从远程服务器上获取catalog&#xff0c;增加参数-DarchetypeCataloginternal 如何在i…

android手机生成pdf格式文件,Android根据pdf模板生成pdf文件

1 public voidFillPdfTemplate(String id) {2 android.icu.text.SimpleDateFormat simpleDateFormat 3 new android.icu.text.SimpleDateFormat("HHmmss");//HH:mm:ss4 //设置默认时区5 simpleDateFormat.setTimeZone(android.icu.util.TimeZone.getTimeZone("G…

栈的应用--数制转换

十进制N和其他d进制 N(N div d)XdN mod d &#xff08;其中&#xff1a;div为整除运算&#xff0c;mod为求余运算&#xff09; void conversion(){SqStack S;int N;SElemType e;Init_Stack(S);scanf("%d",&N);while(N){Push(S,N%8);NN/8;}while(!Stack_Empty(S…

radio按钮点击文字选中按钮

<input type"radio" name"name" id"rd" value" " /><label for"rd">测试</label> 转载于:https://www.cnblogs.com/kevin1988/p/3727041.html

tokumx经营报表

#见数据库列表 show dbs#切换/创建数据库(当创建一个集合(table)的时候会自己主动创建当前数据库)use admin;#添加用户 db.addUser("zhoulf ","123456",true)#更改password&#xff08;为已经存在的用户更改password&#xff09; db.addUser("zhoulf …