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>

    加入深度后的效果;

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

  • 相关阅读:
    cf1131f 构造+并查集
    多源最短路小结
    bzoj2200拓扑排序+最短路+联通块
    cf478d 线性dp好题
    cf919D 线性dp+拓扑排序
    hiho1460 rmq模板题
    最小标示法模板 poj1509
    JAVA动态代理机制分析guide
    java动态代理(JDK和cglib)
    AOP面向切面编程
  • 原文地址:https://www.cnblogs.com/lyd447113735/p/8182377.html
Copyright © 2011-2022 走看看