Android利用阴影让标题栏出现层次感

首先上两张图看看效果

没有阴影

是不是感觉死气沉沉的?

这里写图片描述

有阴影

当当当当,层次感就出来啦,特别是标题栏下面有个列表框就更加骚气啦。

这里写图片描述

实现方法

其实就是使用shape的gradient,然后在调用,我的这个标题栏是自己做的,布局代码在下面。

    <gradient android:angle="270"
        android:startColor="@color/colorRed"
        android:centerColor="@color/colorRed"
        android:centerY="0.9"></gradient>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorWhite">
    <TextView
        style="@style/normalFont"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="15dp"
        android:background="@drawable/t" />
</RelativeLayout>

android:angle=”270” 表示从上往下渐变
android:centerY=”0.9” 表示把中心Y轴偏移到很下面。


如果是Android自带的Theme,就像我用的就是Android自带的AppTheme风格,你去设置colorPrimary对应drawable文件程序是无法找到drawable资源的。

提示:创建shape文件的时候,记得如果是英文字母的话要写成小写,如果有大写也会编译错误的。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值