zoukankan      html  css  js  c++  java
  • Android中的elevation

      在安卓5.0之前是使用二维坐标来记录屏幕里的点,我们常用的width和height就是用来表示屏幕的z,y坐标。5.0之后开始加入三维坐标,除了x,y还另外增加了z来表示深度,也就是立体距离,这个z在安卓中用elevation

      用两个有背景色的文本框来测试elevation的效果:

    未使用elevation时的源代码:

     1 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2     android:layout_width="match_parent"
     3     android:layout_height="match_parent">
     4 
     5     <TextView
     6         android:layout_width="300px"
     7         android:layout_height="300px"
     8         android:layout_gravity="center"
     9         android:background="#be2b2b"
    10        
    11         />
    12 
    13     <TextView
    14         android:layout_width="100px"
    15         android:layout_height="100px"
    16         android:layout_gravity="center"
    17         android:background="#5abe2b" />
    18 
    19 
    20 </FrameLayout>

     效果:小的文本框在大的文本框的上面

    使用elevation后的源代码:带原代码的第一个文本框中加入

    android:elevation="1px"

    源代码:

     1 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2     android:layout_width="match_parent"
     3     android:layout_height="match_parent"
     4     >
     5 
     6     <TextView
     7         android:layout_width="300px"
     8         android:layout_height="300px"
     9         android:background="#be2b2b"
    10         android:layout_gravity="center"
    11         android:elevation="1px"
    12         />
    13 
    14     <TextView
    15         android:layout_width="100px"
    16         android:layout_height="100px"
    17         android:background="#5abe2b"
    18         android:layout_gravity="center"
    19         />
    20 
    21 
    22 </FrameLayout>

    加入深度后的效果;

    可以看到加了深度之后原本在上面的文本框被有深度的文本框覆盖

  • 相关阅读:
    死磕 java线程系列之自己动手写一个线程池(续)
    Spring Boot (十): Spring Boot Admin 监控 Spring Boot 应用
    opencv之为图像添加边界
    协作,才能更好的中断线程
    Java并发——线程池Executor框架
    神经网络dropout
    xgboost
    物体检测-毕业设计项目回顾
    计算机网络-TCP连接
    gbdt推导和代码
  • 原文地址:https://www.cnblogs.com/lyd447113735/p/8182377.html
Copyright © 2011-2022 走看看