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.pswp.cn/news/375906.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/375906.shtml
英文地址,請注明出處:http://en.pswp.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 …