UI系列__区分style selector在drawable文件夹下还是在value下

 Values文件夹      

   · arrays.xml:定义数组数据;
   · colors.xml:定义表示颜色的数据;
   · dimens.xml:定义尺度,可以使用Resources.getDimension()获得这些资源;
   · strings.xml:定义字符串,可以使用Resources.getString()或Resources.getText()方法获得这些资源;
   · styles.xml:定义显示的样式文件;

        都是<resources />包围

        dimens      主要定义文字大小sp,组件的height width
        Styles      样式 如:Dialog的无标题 透明 什么  如:TextView的文字大小 宽高都可以  

res  /values  /dimens.xml
<resources>
    <dimen name="textSize_TextView">30sp</dimen>
    <dimen name="width_EditText">400dp</dimen>
    <dimen name="height_EditText">100dp</dimen>
</resources>

res  /values  /colors.xml
<resources>
    <color name="blue">#3399cc</color>
    <color name="red">#cc3300</color>
</resources>

res  /values  /styles.xml
    <style name="editText_style">
        <item name="android:textColor">@color/blue</item>
        <item name="android:gravity">center</item>
        <item name="android:text">"样式"</item>
        <item name="android:textSize">18sp</item>
        <item name="android:layout_height">200dp</item>
        <item name="android:layout_width">500dp</item>
        <item name="android:layout_margin">10dp</item>
    </style>

main .xml
    <!-- dimen和color的使用 -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="TextView  textSize=30sp"
        android:textSize="@dimen/textSize_TextView"
        android:layout_margin="10dp"
         />
    <EditText 
        android:layout_width="@dimen/width_EditText"
        android:layout_height="@dimen/height_EditText"
        android:hint="EditText width:500  height:200"
        android:textColorHint="@color/red"
        android:layout_margin="10dp"
        />
    <!-- style和selector的使用 -->
   <EditText         
        style="@style/editText_style"
        android:background="@drawable/edittext_selector"
       />  
   
main.xml中使用到的style样式 是在values文件夹下
                     而用到的background则是在drawable文件夹下 
   <selector />  <shape  /> 这些都在drawable文件夹下

   drawable文件夹

                    一般用来放置一些xml文件 如样式,常被android:background="@drawable/xxx"访问

drawable /bg_edittext_normal
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <corners android:radius="3dp"  />
    <solid   android:color="#FFFFFF"  />
    <stroke  android:width="2dp"
             android:color="#ffcc00"/>
</shape>

drawable /bg_edittext_focused
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <corners android:radius="3dp"/>
    <solid   android:color="#FFFFFF"/>
    <stroke  android:width="2dp"
             android:color="@color/blue"  />
</shape>

drawable /edittext_selector
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
     <item android:state_focused="false" android:drawable="@drawable/bg_edittext_normal"></item>
     <item android:state_focused="true" android:drawable="@drawable/bg_edittext_focused"></item>    
</selector>
     <!--  上面写成android:background="@drawable/bg_edittext_normal"  编译通过 但一运行就退出 
            记住了 是 android:drawable 不是android:background -->


      截图:

     
EditText获取焦点 通过selector 变色

          

        
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这些函数都是用于设置 LVGL 中的 Flexbox 布局相关的属性。 - `void lv_obj_set_flex_grow(lv_obj_t * obj, uint8_t grow);` 用于设置一个对象在 Flexbox 布局中的 grow 属性值,即当有多余的空间时,该对象能够按照比例分配多余的空间。grow 属性值越大,该对象获得的多余空间就越多。 - `void lv_style_set_flex_flow(lv_style_t * style, lv_flex_flow_t value);` 用于设置样式中 Flexbox 布局的 flow 属性,即 Flexbox 中主轴和交叉轴的方向。 - `void lv_style_set_flex_main_place(lv_style_t * style, lv_flex_align_t value);` 用于设置样式中 Flexbox 布局中主轴对齐方式。 - `void lv_style_set_flex_cross_place(lv_style_t * style, lv_flex_align_t value);` 用于设置样式中 Flexbox 布局中交叉轴对齐方式。 - `void lv_style_set_flex_track_place(lv_style_t * style, lv_flex_align_t value);` 用于设置样式中 Flexbox 布局中 track 对齐方式。 - `void lv_style_set_flex_grow(lv_style_t * style, uint8_t value);` 用于设置样式中 Flexbox 布局中对象的 grow 属性值。 - `void lv_obj_set_style_flex_flow(lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector);` 用于设置一个对象在指定的样式选择器中的 Flexbox 布局的 flow 属性。 - `void lv_obj_set_style_flex_main_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector);` 用于设置一个对象在指定的样式选择器中的 Flexbox 布局中主轴对齐方式。 - `void lv_obj_set_style_flex_cross_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector);` 用于设置一个对象在指定的样式选择器中的 Flexbox 布局中交叉轴对齐方式。 - `void lv_obj_set_style_flex_track_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector);` 用于设置一个对象在指定的样式选择器中的 Flexbox 布局中 track 对齐方式。 - `void lv_obj_set_style_flex_grow(lv_obj_t * obj, uint8_t value, lv_style_selector_t selector);` 用于设置一个对象在指定的样式选择器中的 Flexbox 布局的 grow 属性值。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值