Android 在xml中配置 float 和 integer 值

一、float的配置方法

andriod 默认不支持float型的设置,在values 下的新建floats.xml 文件,在内部添加如下代码:

<resources>
    <item name="chart_view_line_width" format="float" type="dimen"> 3.3</item>
    <item name="chart_view_text_size" format="float" type="dimen">17</item>
</resources>

在代码中的使用方法是:

r.setLineWidth(Float.parseFloat(mContext.getResources().getString(R.string.chart_view_line_width)));
r.setChartValuesTextSize(Float.parseFloat(mContext.getResources().getString(R.string.chart_view_text_size)));

二、integer的配置方法

android 默认支持integer形的设置,在values下新建integers.xml文件,如下:

<resources>
    <integer name="emotion_columm_num">14</integer>
    <integer name="right_icon_visibility">0</integer>
    <integer name="webview_fix_height">65</integer>
    <integer name="right_icon_orientation">1</integer>
    <integer name="dashboard_flip_interval">4000</integer>
    <integer name="pairing_duration">100</integer>
</resources>

代码中使用是:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/select"
    android:oneshot="false" >  

    <item
        android:drawable="@drawable/pairing_01"
        android:duration="@integer/pairing_duration"/>
    <item
        android:drawable="@drawable/pairing_02"
        android:duration="@integer/pairing_duration"/>
    <item
        android:drawable="@drawable/pairing_03"
        android:duration="@integer/pairing_duration"/>  

</animation-list>

mContext.getResources().getInteger(R.integer.columns);

Android 在xml中配置 float 和 integer 值

时间: 2024-08-07 18:37:03

Android 在xml中配置 float 和 integer 值的相关文章

源码跟读,Spring是如何解析和加载xml中配置的beans

Spring版本基于: 跟踪代码源码基于: https://github.com/deng-cc/KeepLearning commit id:c009ce47bd19e1faf9e07f12086cd440b7799a63 1.配置启动Spring所需的监听器 web.xml中配置监听器 <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-cla

jsp 使用application.getInitParameter来获取web.xml中配置参数

jsp中9个内置对象之一application,它的数据对整个web应用都有效,application有一个重要的用途就是获取web.xm中的配置参数,这样可以提高代码的移植性.应用案例如下: 在web.xml中配置如下代码: <context-param> <param-name>driver</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </context-p

在struts-config.xml中配置validator-plugin导致404 Servlet action is not available

就是在struts-config.xml中添加了这么一段 <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/> <set-property pro

在配置文件web.xml中配置Struts2的启动信息

在配置文件web.xml中配置Struts2的启动信息: <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://ja

ssm整合shiro时web。xml中配置filter,tomcat报错

当我们使用ssm框架整合进行项目开发,使用Shiro作为安全验证管理,在web.xml中配置Shiro过滤器后 启动Tomcat会报错: Error during artifact deployment. See server log for details. <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property na

读取xml中的指定节点的值

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 /// <summary>         /// 读取xml中的指定节点的值        /// </summary>         private string ReadXmlNode(string filename)        {            string result = "-1";            XmlDocu

Android通过xml文件配置数据库

之前一段时间自己封装了两个数据库,一个是ORM数据库,另一个是事件流数据库,项目相应的地址如下: ORM数据库:https://github.com/wenjiang/SimpleAndroidORM 事件流数据库:https://github.com/wenjiang/EventStreamDB 有兴趣的人可以上去看看. 如果要讲这两个项目,一篇文章的篇幅是放不下的,所以就只是每篇都只讲一点点. 两个自己写的数据库都有一个必须用到的地方:在xml文件中配置数据库. 利用文件配置数据库在很多语言

服务器启动时Webapp的web.xml中配置的加载顺序

一 1.启动一个WEB项目的时候,WEB容器会去读取它的配置文件web.xml,读取<listener>和<context-param>两个结点. 2.紧急着,容创建一个ServletContext(servlet上下文),这个web项目的所有部分都将共享这个上下文. 3.容器将<context-param>转换为键值对,并交给servletContext. 4.容器创建<listener>中的类实例,创建监听器. 二  Load-on-startup Lo

servlet3.0以后无需在web.xml中配置servlet

//下面这句话代替了web.xml中对servlet的配置 @WebServlet("/Upload") public class Upload extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletExceptio