国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

解決Android Studio Design界面不顯示layout控件的問題

瀏覽:102日期:2022-09-26 13:49:06

Android Studio更新到3.1.3后,發現拖到Design中的控件在預覽界面中不顯示;

解決辦法:

在Styles.xml中的parent='...'中的Theme前添加Base

<resources> <!-- Base application theme. --> <style name='AppTheme' parent='Base.Theme.AppCompat.Light.DarkActionBar'> <!-- Customize your theme here. --> <item name='colorPrimary'>@color/colorPrimary</item> <item name='colorPrimaryDark'>@color/colorPrimaryDark</item> <item name='colorAccent'>@color/colorAccent</item> </style></resources>

補充知識:AndroidStudio XML文件之style標簽詳解

前言:

Android的樣式一般定義在res/values/styles.xml文件中,其中有一個根元素resource,樣式通過嵌套子標簽style來完成,style可以嵌套多個item標簽來設置不同的屬性,從而提高復用率。

什么是Style:

style是一個標簽,該標簽里可以嵌套多個item子標簽,通過item標簽的name設置不同的屬性,多個item組合起來就是一個style樣式

示例:

<style name='DefaultProgressDialog' parent='android:style/Theme.Dialog' > <item name='android:windowFrame'>@null</item> <item name='android:windowNoTitle'>true</item> <item name='android:windowBackground'>@android:color/transparent</item> <item name='android:windowIsFloating'>true</item> <item name='android:windowContentOverlay'>@null</item> </style>

Style標簽里面的屬性:

name='XXX' 定義該style樣式的name名稱

parent='XXX' 可以繼承自哪一個Style標簽,繼承以后可對父標簽已經有的屬性進行重寫

Style標簽里可以嵌套的標簽:

item標簽的屬性:

name='XXX' name里面的值可以為任意字符串,對應的是某一個view的屬性值(如果要引用的view不存在這個屬性,默認為這個屬性無效(忽略這個屬性),并不會報錯)

自定義控件里面的屬性值怎么在style的item標簽里聲明:

在主工程的時候要加上包名:

<style name='navigationbar_radiogroup_style'> <item name='com.mobeta.android.dslv.view:drawableSize'>@dimen/dp20</item> </style>

在module或其他類庫的話,什么都不用加:

<style name='navigationbar_radiogroup_style'> <item name='drawableSize'>@dimen/dp20</item> </style>

常用item屬性:

窗口進出動畫設置:

<style name='WheelSelect' parent='@android:style/Animation'> <item name='android:windowEnterAnimation'>@anim/wheel_select_enter</item> <item name='android:windowExitAnimation'>@anim/wheel_select_exit</item> </style>

設置Dialog的屬性:

<style name='DefaultProgressDialog' parent='android:style/Theme.Dialog'> <item name='android:windowFrame'>@null</item> <item name='android:windowNoTitle'>true</item> <item name='android:windowBackground'>@android:color/transparent</item> <item name='android:windowIsFloating'>true</item> <item name='android:windowContentOverlay'>@null</item> </style>

各屬性顏色的位置

解決Android Studio Design界面不顯示layout控件的問題

1.colorPrimary 應用的主要色調,actionBar默認使用該顏色,Toolbar導航欄的底色2.colorPrimaryDark 應用的主要暗色調,statusBarColor默認使用該顏色3.statusBarColor 狀態欄顏色,默認使用colorPrimaryDark4.windowBackground 窗口背景顏色5.navigationBarColor 底部欄顏色6.colorForeground 應用的前景色,ListView的分割線,switch滑動區默認使用該顏色7.colorBackground 應用的背景色,popMenu的背景默認使用該顏色8.colorAccent CheckBox,RadioButton,SwitchCompat等一般控件的選中效果默認采用該顏色9.colorControlNormal CheckBox,RadioButton,SwitchCompat等默認狀態的顏色。10.colorControlHighlight 控件按壓時的色調11.colorControlActivated 控件選中時的顏色,默認使用colorAccent12.colorButtonNormal 默認按鈕的背景顏色13.editTextColor 默認EditView輸入框字體的顏色。14.textColor Button,textView的文字顏色15.textColorPrimary DisableOnly RadioButton checkbox等控件的文字16.textColorPrimary 應用的主要文字顏色,actionBar的標題文字默認使用該顏色17.colorSwitchThumbNormal: switch thumbs 默認狀態的顏色. (switch off)

以上這篇解決Android Studio Design界面不顯示layout控件的問題就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Android
相關文章:
主站蜘蛛池模板: 丘北县| 榆社县| 阿尔山市| 乌鲁木齐县| 绥江县| 华池县| 绥江县| 夏津县| 屯昌县| 贡嘎县| 恩施市| 广安市| 湘西| 澄迈县| 汶上县| 博野县| 眉山市| 全椒县| 泸州市| 磐安县| 云浮市| 革吉县| 阿尔山市| 临泉县| 尉氏县| 电白县| 万盛区| 德钦县| 清原| 黄龙县| 正安县| 天门市| 阿坝| 哈密市| 诸城市| 时尚| 商水县| 大理市| 九台市| 柘荣县| 西昌市|