日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android设置布局背景为白色的三种方法

發布時間:2025/4/14 Android 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android设置布局背景为白色的三种方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、在xml文件里可以直接設置: android:background="#ffffff" 其他顏色可以看這里;http://blog.csdn.net/yanzi1225627/article/details/8581270 二、在java文件里設置: LinearLayout myLayout = () findViewById(R.id.linearLayout1); myLayout.setBackgroundColor(Color.WHITE); 三、在AndroidManifest.xml里利用android:theme來設置,這個命令還是很強大的,如下所示: theme的設置 可以設置為系統自帶的格式,也可以自定義格式。 A: 系統自帶格式 @android:style/Theme.Black ?//背景黑色-有標題-非全屏 @android:style/Theme.Black.NoTitleBar //背景黑色-無標題-非全屏 @android:style/Theme.Black.NoTitleBar.Fullscreen //背景黑色-無標題-全屏顯示 @android:style/Theme.Dialog //對話框顯示 @android:style/Theme.InputMethod @android:style/Theme.Light ? ?//背景白色-有標題-非全屏 @android:style/Theme.Light.NoTitleBar //背景白色-無標題-非全屏 @android:style/Theme.Light.NoTitleBar.Fullscreen //背景白色-無標題-全屏顯示 @android:style/Theme.Light.Panel @android:style/Theme.Light.WallpaperSettings //背景透明 @android:style/Theme.NoDisplay @android:style/Theme.Translucent.NoTitleBar.Fullscreen //半透明、無標題欄、全屏 @android:style/Theme.Wallpaper.NoTitleBar.Fullscreen 可以在單個Activity里設置,也可以在applicaiton里全局設置。比如: <activity android:screenOrientation="portrait" android:name=".ui.RegisterActivity" android:theme="@android:style/Theme.NoTitleBar"></activity> B:也可以自定義 在activity里加入 android:theme="@style/MyTitleBar" 再在 style.xml里加入 <style name="MyTitleBar" parent="android:Theme"> <item name="android:windowTitleSize">50dip</item> <item name="android:windowTitleBackgroundStyle">@style/MyTitleBackground</item> <item name="android:windowTitleStyle">@style/WindowTitle</item> </style> <!-- 自定義標題欄背景圖 --> <style name="MyTitleBackground" parent="android:TextAppearance.WindowTitle"> <item name="android:background">@drawable/bg_topbar</item> </style> <style name="WindowTitle" parent="android:TextAppearance.WindowTitle"> <item name="android:singleLine">true</item> </style> 這里的parent是繼承于android:Theme,所以在下面的樣式里,只能是window開頭的樣式才起作用,所有樣式請參考\sdk\docs\reference\android\R.attr.html, 也可以設置windowTitleBackgroundStyle 為@style/MyTitleBackground,這樣就可以在MyTitleBackground里,設置背景圖。

轉載于:https://www.cnblogs.com/lgh1992314/p/5834767.html

總結

以上是生活随笔為你收集整理的Android设置布局背景为白色的三种方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。