zoukankan      html  css  js  c++  java
  • 定义字符串,颜色,尺寸资源文件

    在工程的res/values/下面可以定义String.xml , colors.xml ,  dimens.xml 来表示布局文件中需要使用的一些数据

    例如:

    dimens.xml定义布局文件中控件的尺寸

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <dimen name="spacing">8dp</dimen>
        <!-- 定义GridView组件中每个单元格的宽度、高度 -->
        <dimen name="cell_width">60dp</dimen>
        <dimen name="cell_height">66dp</dimen>
        <!-- 定义主程序的标题的字体大小 -->
        <dimen name="title_font_size">18sp</dimen>
    
    </resources>

    布局文件main.xml引入

     <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/app_name"
            android:textSize="@dimen/title_font_size" />
        <!-- 定义一个GridView组件,使用尺度资源中定义的长度来指定水平间距、垂直间距 -->
    
        <GridView
            android:id="@+id/grid01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:horizontalSpacing="@dimen/spacing"
            android:numColumns="3"
            android:verticalSpacing="@dimen/spacing" >
        </GridView>

    引入方式是: @文件名字/某某属性
    当然完全可以用style.xml样式实现, 这里只是说明一些其他情况.

  • 相关阅读:
    JSONP(处理跨域问题)
    Bootstrap 按钮
    input file 图片上传展示重新上传
    Bootstrap 表单
    Bootstrap 表格
    Bootstrap 代码
    Bootstrap 排版 文本
    bootstrap 栅格calss
    Bootsrap 直接使用
    Bootstrap3和Bootsrap4的区别
  • 原文地址:https://www.cnblogs.com/android-zcq/p/3147361.html
Copyright © 2011-2022 走看看