zoukankan      html  css  js  c++  java
  • Android layer-list(3)

    

    Android layer-list(3)

    在附录文章3、4的基础上,就Android layer-list再写一个较为复杂的应用。
    先写布局文件,该布局涉及到LinearLayoutCompat,关于LinearLayoutCompat参看附录文章5。
    布局文件activity_main.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/holo_orange_light"
        tools:context="zhangphil.demo.MainActivity">
    
        <android.support.v7.widget.LinearLayoutCompat xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dip"
            android:background="@drawable/layer_list"
            android:orientation="vertical"
            app:divider="@drawable/shape"
            app:dividerPadding="50dip"
            app:showDividers="middle">
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="zhang phil @csdn" />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="zhang phil @csdn" />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="zhang phil @csdn" />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="zhang phil @csdn" />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="zhang phil @csdn" />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="zhang phil @csdn" />
    
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="zhang phil @csdn" />
    
        </android.support.v7.widget.LinearLayoutCompat>
    </RelativeLayout>
    


    其中activity_main.xml中的LinearLayoutCompat涉及到了添加分割线,需要再写一个shape文件,drawable/shape.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    
        <solid android:color="@android:color/darker_gray" />
    
        <!-- 分割线的高度 -->
        <size android:height="2dip" />
    
    </shape>


    drawable/layer_list.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item>
            <shape>
                <corners
                    android:bottomLeftRadius="20dip"
                    android:bottomRightRadius="20dip"
                    android:topLeftRadius="20dip"
                    android:topRightRadius="20dip" />
                <solid android:color="@android:color/background_light" />
    
                <stroke
                    android:width="2dip"
                    android:color="@android:color/darker_gray" />
            </shape>
        </item>
    
        <item android:drawable="@mipmap/ic_launcher"></item>
    
    </layer-list>


    代码运行结果:



    附录文章:
    1,《Android AnimationDrawable动画与APP启动引导页面》链接地址:http://blog.csdn.net/zhangphil/article/details/47416915 
    2,《Android ImageView的setImageLevel和level-list使用简介》链接地址:http://blog.csdn.net/zhangphil/article/details/48936209
    3,《Android layer-list(1)》链接地址:http://blog.csdn.net/zhangphil/article/details/51720924
    4,《Android layer-list:联合shape(2)》链接地址:http://blog.csdn.net/zhangphil/article/details/51721283
    5,《Android Material Design :LinearLayoutCompat添加分割线divider》链接地址:http://blog.csdn.net/zhangphil/article/details/48899585

  • 相关阅读:
    iCloud文件同步至Mac本地磁盘
    hive多分区写入
    清理hdfs小文件shell脚本
    大数据应用建设开源工具-update2019-07
    手机号码段:中国工信.三大运营商号段-update2019-09
    sparkf:spark-sql替换hive查询引擎
    hivef:hive 执行 sql 文件
    azkaban 工作流2.0开发示例
    MySQL-时间+日期函数
    大数据仓库对业务数据的几个基本要求
  • 原文地址:https://www.cnblogs.com/hehehaha/p/6147303.html
Copyright © 2011-2022 走看看