首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏全栈程序员必看

    android declare-styleable 和style,android – declare-styleable和style之间的区别

    在attrs.xml中,您可以直接在“资源”部分内或在“declare-styleable”中声明自定义属性: 所以现在我们将“attrib1”定义为不风格,“attrib2”为风格。 在layout / someactivity.xml中,我们可以直接使用这些属性(不需要命名空间): 您可以在style.xml声明中使用“styleable”属性“attrib2”。

    73530编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    declare-styleable使用

    declare-styleable是给自定义控件添加自定义属性用的 attr中 在attrs.xml中设置declare-styleable,name是PersonAttr <? > <resources> <declare-styleable name="PersonAttr"> <attr name="name" format="reference > </resources> format就是格式,里面的就是这个属性对应的格式,下面列出来大致的格式有: reference:参考某一资源ID,以此类推 属性定义: <declare-<em>styleable</em> name = "名称"> <attr name = "background" format = "reference" /> </declare-styleable> 属性使用: <ImageView (R.styleable.PersonAttr_age, 15); int weight = tArray.getInt(R.styleable.PersonAttr_weight, 1

    56220编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    android declare-styleable 和style,Android 关于declare-styleable属性的写法….

    我看了一些资料,说写在declare-styleable系统会自动生成数组….. 我不太明白这实际应用是什么? 如果说自动帮你生成了数组,方便使用,那写在外面的三个又有什么作用? attr name=”titleTextColor” format=”color” /> <attr name=”titleTextSize” format=”dimension” /> <declare-styleable ”> <attr name=”titleText” /> <attr name=”titleTextColor” /> <attr name=”titleTextSize” /> </declare-styleable <declare-styleable name=”CustomTitleView”> <attr name=”titleText” format=”string” /> <attr name=”titleTextColor ” format=”color” /> <attr name=”titleTextSize” format=”dimension” /> </declare-styleable> 自定义style 声明和引用的关系

    51230编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    cordova declare styleable 错误「建议收藏」

    出现 ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute 可以使用cordova plugin add cordova-plugin-file-opener2

    53520编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    declare-styleable的使用

    declare-styleable是给自定义控件添加自定义属性用的 1.首先,先写attrs.xml <?xml version="1.0" encoding="utf-8"? > <resources> <declare-styleable name="TestAttr"> <attr name="name" format="reference" / ); String name = tArray.getString(R.styleable.TestAttr_name); System.out.println("name = " + name); int age = tArray.getInt(R.styleable.TestAttr_age, 200); System.out.println ("age = " + age); float demin = tArray.getDimension(R.styleable.TestAttr_textSize,0);

    61120编辑于 2022-09-06
  • 来自专栏技术小黑屋

    自定义控件进阶:declare-styleable重用attr

    > <resources> <declare-styleable name="ExTextView"> <attr name="enableOnPad" format="boolean " /> <attr name="supportDeviceType" format="reference"/> </declare-styleable> <declare-styleable " /> <attr name="supportDeviceType" format="reference"/> </declare-styleable> <declare-styleable .但是当我使用R.styleable.ExEditText_supportDeviceType时候,R文件却没有生成,重新清理了工程还是不生效,不知道是否为adt插件的问题.其他人也遇到了这样的问题. "/> </declare-styleable> </resources> 每次引用attr后,建议清理一下工程,确保R文件重新生成.

    1.8K10发布于 2018-09-04
  • 来自专栏全栈程序员必看

    Android自定义View之declare-styleable记录

    format 值类型 reference 资源ID color 颜色值 dimension 尺寸值 float 浮点值 string 字符串 fraction 百分数 <declare-styleable value="0" /> <flag name="stateWindowvisible" value="1" /> </attr> </declare-styleable

    30810编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    declare-styleable:自定义控件的属性

    ); buttonNum = a.getInt(R.styleable.ToolBar_buttonNum, 5); itemBg = a.getResourceId(R.styleable.ToolBar_itemBackground 该文件是定义属性名和格式的地方,需要用<declare-styleable name=”ToolBar”></declare-styleable>包围所有属性。 1.定义: 1 2 3 <declare-styleable name="My"> <attr name="label" format="reference" > </declare-styleable </declare-styleable> 2.使用: 1 <Button zkx:myWidth="100dip"/> 五、float:浮点型 1.定义: 1 2 3 <declare-styleable " /> </declare-styleable> 2.使用: 1 <rotate zkx:pivotX="200%"/> 八、fraction:百分数 1.定义: 1 2 3 <declare-styleable

    89430编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    自定义属性 declare-styleable数据类型简介:

    1.定义: 1 2 3 <declare-styleable name=”My”> <attr name=”label” format=”reference” > </declare-styleable > </declare-styleable> 2.使用: 1 <Button zkx:isVisible=”false”/> 四、dimension:尺寸值 1.定义: 1 2 3 <declare-styleable ” /> </declare-styleable> 2.使用: 1 <alpha zkx:fromAlpha=”0.3″/> 六、integer:整型 1.定义: 1 2 3 <declare-styleable =”string” /> </declare-styleable> 2.使用: 1 <rotate zkx:pivotX=”200%”/> 八、fraction:百分数 1.定义: 1 2 3 <declare-styleable obtainStyledAttributes(attrs, R.styleable.EasyHeadViewClick) if (attributes !

    87420编辑于 2022-09-15
  • 来自专栏向治洪

    深入理解Android 自定义attr Style styleable以及其应用

    attr和styleable的关系 首先要明确一点,attr不依赖于styleable,styleable只是为了方便attr的使用。 ,我们可以在R文件里自动生成一个int[],数组里面的int就是定义在styleable里面的attr的id。 所以我们在获取属性的时候就可以直接使用styleable数组来获取一系列的属性。 (set,R.styleable.custom_attrs); 由上面的例子可以知道,定义一个declare-styleable,在获取属性的时候为我们自动提供了一个属性数组。 此外,我觉得使用declare-styleable的方式有利于我们我们把相关的属性组织起来,有一个分组的概念,属性的使用范围更加明确。

    2.7K61发布于 2018-02-01
  • 来自专栏全栈程序员必看

    android 自定义控件 使用declare-styleable进行配置属性(源码角度)「建议收藏」

    最近在模仿今日头条,发现它的很多属性都是通过自定义控件并设定相关的配置属性进行配置,于是便查询了解了下declare-styleable,下面我把自己的使用感受和如何使用进行说明下。 declare-styleable:declare-styleable是给自定义控件添加自定义属性用的。 ); 这个就是系统在默认的资源文件R.styleable中去获取相关的配置。 name = “名称”> <attr name = “textColor” format = “color” /> </declare-styleable> 3. boolean:布尔值 <declare-styleable /> </declare-styleable> 5. float:浮点值。

    1.8K20编辑于 2022-09-14
  • 来自专栏伟大程序猿的诞生

    Android自定义View【实战教程】1⃣️----attrs.xml详解

    fillXY" value="0"/> <enum name="center" value="1"/> </attr> //自定义控件的主题样式 <declare-styleable 定义: <declare-styleable name = "名称"> <attr name = "background" format = "reference " /> </declare-styleable> 使用: <ImageView android:layout_width = "42dip" name = "名称"> <attr name = "focusable" format = "boolean" /> </declare-styleable> name = "名称"> <attr name = "background" format = "reference|color" /> </declare-styleable>

    75720发布于 2019-01-21
  • 来自专栏风吹杨柳

    实习杂记(25):View基类里面的LayoutParams

    * @attr ref android.R.styleable#RelativeLayout_Layout_layout_toLeftOf * @attr ref android.R.styleable * @attr ref android.R.styleable#RelativeLayout_Layout_layout_below * @attr ref android.R.styleable * @attr ref android.R.styleable#RelativeLayout_Layout_layout_alignTop * @attr ref android.R.styleable android.R.styleable#RelativeLayout_Layout_layout_centerInParent * @attr ref android.R.styleable * @attr ref android.R.styleable#RelativeLayout_Layout_layout_alignEnd * @attr ref android.R.styleable

    72110发布于 2019-07-08
  • 来自专栏Android知识点总结

    写一个自定义控件attrs自动生成代码工具

    --自定义进度条--> <declare-styleable name="TolyProgressBar"> <! (R.styleable.TolyProgressBar_z_pb_on_color, mPbOnColor); mPbTxtSize = (int) a.getDimension(R.styleable.TolyProgressBar_z_pb_txt_size --自定义进度条--> * <declare-styleable name="TolyProgressBar"> * <! , mPbTxtColor); sb.append("m" + s + " = a.getColor(R.styleable." + styleableName + " , mPbTxtColor); sb.append("m" + s + " = a.getBoolean(R.styleable." + styleableName +

    58440发布于 2018-12-10
  • 来自专栏wOw的Android小站

    [Android][Framework] PackageManagerService之AndroidManifest的解析

    , R.styleable.AndroidManifestActivity_label, R.styleable.AndroidManifestActivity_icon , R.styleable.AndroidManifestActivity_roundIcon, R.styleable.AndroidManifestActivity_logo R.styleable.AndroidManifestActivity_process, R.styleable.AndroidManifestActivity_description , R.styleable.AndroidManifestActivity_enabled); } mParseActivityArgs.tag , false); } a.info.theme = sa.getResourceId(R.styleable.AndroidManifestActivity_theme, 0);

    1.6K20发布于 2020-01-20
  • 来自专栏全栈程序员必看

    Attributable_文件属性里没有自定义

    R文件中会有styleable和attr这两个类,当我们要使用哪个属性集合或哪个属性的时候用的是styleable, 而attr类定义的仅仅是attr这个属性在layout中的id. (1)属性定义: <declare-styleable name = "名称"> <attr name = "background" format = "reference" /> </declare-styleable (1)属性定义: <declare-styleable name = "名称"> <attr name = "textColor" format = "color" /> </declare-styleable (1)属性定义: <declare-styleable name = "名称"> <attr name = "focusable" format = "boolean" /> </declare-styleable (1)属性定义: <declare-styleable name = "MapView"> <attr name = "apiKey" format = "string" /> </declare-styleable

    86540编辑于 2022-11-17
  • 来自专栏全栈程序员必看

    android中怎么在View构造的attrs中拿到android给的属性以及attrs属性介绍[通俗易懂]

    (1)属性定义: <declare-styleable name = "名称"> <attr name = "background" format = "reference" /> </declare-styleable (1)属性定义: <declare-styleable name = "名称"> <attr name = "textColor" format = "color" /> </declare-styleable (1)属性定义: <declare-styleable name = "名称"> <attr name = "focusable" format = "boolean" /> </declare-styleable (1)属性定义: <declare-styleable name = "名称"> <attr name = "layout_width" format = "dimension" /> </declare-styleable (1)属性定义: <declare-styleable name = "MapView"> <attr name = "apiKey" format = "string" /> </declare-styleable

    1.8K110编辑于 2022-11-02
  • 来自专栏风吹杨柳

    2014-11-3Android学习------关于R.styleable的问题(一)API学习--------GIF动画实现

    转载请注明,联系请邮件nlp30508@qq.com 这节主要学习下   R.styleable   这个一般出现在定义的attrs.xml文件中, 命名方式是:<declare-styleable :R.styleable.PieChart_showText This code declares two custom attributes, showText and labelPosition , that belong to a styleable entity named PieChart.  上面的代码定义了两个自定义属性,showText 和labelPosition,他们属于styleable类型的一个名叫PieChart实体类的两个属性。 这里告诉我们,一般我们去定义自己的视图类的时候,类名最好使用 <declare-styleable name="PieChart">中name的定义的名字,与它保持一致。当然它也不是绝对必要的。

    2.3K20发布于 2019-07-05
  • 来自专栏cwl_Java

    速读原著-Android应用开发入门教程(自定义的视图)

    ); CharSequence s = a.getString(R.styleable.LabelView_text); if (s ! , 0xFF000000)); int textSize = a.getDimensionPixelOffset(R.styleable.LabelView_textSize R.styleable.LabelView 这些内容在 res/values/的 attrs.xml 文件中进行了定义,内容如下所示: <declare-styleable name="LabelView <attr name="textColor" format="color" /> <attr name="textSize" format="dimension" /> </declare-styleable R.styleable.LabelView_text,R.styleable.LabelView_textColor 和 R.styleable.LabelView_textSize 是在源代码中使用的属性

    80110发布于 2020-02-13
  • 来自专栏肖蕾的博客

    仿微信点击拍照长按录制按钮特效

    paint.strokeCap = Paint.Cap.ROUND val array = context.obtainStyledAttributes(attrs, R.styleable.CameraRecordButton ) // 背景 background_color = array.getColor( R.styleable.CameraRecordButton_background_color , 270 ) progress_duration = array.getInt( R.styleable.CameraRecordButton_progress_duration progress * 360, false, paint ) } } 这是xml属性文件: <declare-styleable > <attr name="progress_duration" format="integer" tip="进度耗时,单位毫秒" /> </declare-styleable

    1.4K10发布于 2020-12-21
领券