校园网站建设背景,郑州网站排名优化公司,阳江seo网站推广,企业网站建设意义观看此文注意首先有的UI改颜色#xff0c;没用#xff0c;发现无法更改按钮背景颜色。我的AS下载的是最新版本#xff0c;Button按钮的背景颜色一直都是亮紫色#xff0c;无法更改。为什么呢#xff1f;首先在你的清单文件中看你应用的是哪个主题。我现在用的是这个可能你…观看此文注意首先有的UI改颜色没用发现无法更改按钮背景颜色。我的AS下载的是最新版本Button按钮的背景颜色一直都是亮紫色无法更改。为什么呢首先在你的清单文件中看你应用的是哪个主题。我现在用的是这个可能你的主题用的是上面的默认的原因。方法一将app/res/themes目录下默认的themes代码加上.Bridge即可。修改前style nameTheme.IntelligentWatch parentTheme.MaterialComponents.DayNight.DarkActionBar修改后style nameTheme.IntelligentWatch parentTheme.MaterialComponents.DayNight.DarkActionBar.Bridge方法二自己定义一个主题就是类似我用的但是我这个是没有ActionBar标题栏的你需要自己再去定义一个标题栏然后去清单文件中使用自己定义的主题。style nameTheme.IntelligentWatch.NoActionBaritem namewindowActionBarfalse/itemitem namewindowNoTitletrue/item
/style创建res文件首先我们创建一个res文件。右键res文件夹一Resource typeValues都是放在res\values文件夹下。其Root element父节点只有resources。子元素StringAlt回车可以自动生成。resourcesstring nametitle登录/stringstring-array nameddditemdddd/itemitem2222/item/string-array
/resources双引号可加可不加。打印出来默认去除如果想要双引号则加上转义字符。string-array nameddditem\dddd\/itemitem\2222\/item
/string-array怎么使用呢在布局文件里String在Java文件里getResources().getStringArray(...)2.子元素Color一般是在XML布局文件中使用。组成部分# 透明度红绿蓝(ARGB)每个部分的值0-256resourcescolor namepurple_200#FFBB86FC/colorcolor namepurple_500#FF6200EE/colorcolor namepurple_700#FF3700B3/colorcolor nameteal_200#FF03DAC5/colorcolor nameteal_700#FF018786/colorcolor nameblack#FF000000/colorcolor namewhite#FFFFFFFF/colorcolor nameivory#EEEEEE/color象牙白color nameblue#3161EF/color蓝色color namegray#B3B1B1/color灰色
/resources3.子元素dimen尺寸。比如字体大小等等。resourcesdimen namefab_margin16dp/dimen
/resources二Resource typeDrawable放在res\drawable文件夹下。其Root element父节点有很多这里主要来讲解其中常用的几个。根元素shape形状。在UI控件的background中设置。比如我们想要为按钮创建一个背景。androidshaperectanglering圆环 oval椭圆 rectangle长方形 line线子元素solid中间内容填充的颜色。2.子元素corners拐角的弯曲的弧度3.子元素size大小。4.子元素stroke描边一般给EditText输入框给一个背景的时候会用到这个中间不会填充。5.子元素gradient线性渐变。6.子元素padding间距。?xml version1.0 encodingutf-8?
shape xmlns:androidhttp://schemas.android.com/apk/res/androidsolid android:colorcolor/white/corners android:radius100dp/
/shapeButtonandroid:idid/button_firstandroid:layout_widthmatch_parentandroid:layout_height50dpandroid:textstring/titleandroid:textSize20dpandroid:textColorcolor/blueandroid:backgrounddrawable/loading_btnandroid:layout_margin28dpapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toBottomOfid/textview_first /一般设置在XML布局文件的UI控件的background里面用drawable/xxx就可以了。2.根元素selector选择器。在UI控件的background中设置。比如我们想要点击按钮的时候是蓝色不点击的时候是黑色。不写 android:state_pressedfalse也可以因为默认是false。?xml version1.0 encodingutf-8?
selector xmlns:androidhttp://schemas.android.com/apk/res/androiditem android:state_pressedtrue android:drawablecolor/blue/item android:state_pressedfalse android:drawablecolor/black/
/selector三特殊Resources typeValuesStyle与Themes根元素都是resources。其实你可以发现这两个的子元素都是style而且效果也差不多。那这两个有什么区别呢1.style针对某个控件你可以为你的按钮文字定制一个样式属于比较小的点。注意要加android不然不会生效因为也不会报错。?xml version1.0 encodingutf-8?
resourcesstyle nameMyBtnStyle parentTheme.MaterialComponents.DayNight.DarkActionBar.Bridgeitem nameandroid:layout_height50dp/itemitem nameandroid:textSize25dp/itemitem nameandroid:textColorcolor/blue/itemitem nameandroid:backgrounddrawable/loading_btn/item/style/resources在XML布局中使用的时候只需要在UI控件属性中加入下面这句话即可。stylestyle/MyBtnStylestyle优先级布局文件属性优先级也就是说你在XML布局文件中再次写了字体颜色会覆盖掉style里面的字体颜色。2.themes针对整个应用app是一个怎么样的样式。在最开始的观看此文有介绍。