XML Drawable

android把任何可绘制在屏幕上的图形图像都称为drawable.

XML drawable与像素密度无关,将其放入drawable目录即可。

一、shape drawable

xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    android:radius="3dp"/>
    android:angle="270"
              android:endColor="#cccccc"
              android:startColor="#acacac"/>
二、state list drawable

xmlns:android="http://schemas.android.com/apk/res/android">
android:drawable="@drawable/button_shape_normal"
      android:state_pressed="false"/>
    android:drawable="@drawable/button_shape_pressed"
          android:state_pressed="true"/>
xmlns:android="http://schemas.android.com/apk/res/android">
android:color="#ffffff"
      android:state_pressed="false"/>
    android:color="#556699"
          android:state_pressed="true"/>
三、layer list 与 inset drawable

xmlns:android="http://schemas.android.com/apk/res/android">
    
        android:shape="rectangle">
            android:radius="5dp"/>
            android:angle="90"
                android:centerColor="#303339"
                android:centerY="0.05"
                android:endColor="#000000"
                android:startColor="#000000"/>
        
    
    
        android:drawable="@drawable/button_shape"
               android:insetBottom="5dp"/>
    
效果:出现阴影

你可能感兴趣的:(android)