无聊看到一个第三方有个比较炫酷的效果 于是稍微改了下做成了一个骚气的title 如果大家有用的话可以看看 没用的话就一带而过了
先看个动态效果
第三方依赖库
compile 'com.scwang.wave:MultiWaveHeader:1.0.0-alpha-1'
mainActivity如下
package com.loocan.title;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.loocan.title.util.StatusBarUtil;
public class MainActivity extends AppCompatActivity {
private TextView tv_title;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//状态栏透明和间距处理
StatusBarUtil.immersive(this);
tv_title = findViewById(R.id.tv_title);
tv_title.setText("我是骚气的title");
}
}
activity_main
<?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:orientation="vertical"
tools:context="com.loocan.title.MainActivity">
<include layout="@layout/app_title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<com.scwang.wave.MultiWaveHeader
android:layout_width="match_parent"
android:layout_height="160dp"
android:scaleY="-1" />
<com.scwang.wave.MultiWaveHeader
android:layout_width="match_parent"
android:layout_height="160dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="滚滚长江往东跑"
android:textColor="@color/colorWhite"
android:textSize="30sp" />
</RelativeLayout>
<include layout="@layout/app_title" />
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rlt_base"
android:layout_width="match_parent"
android:layout_height="64dp">
<!--220,0,1,0.1,-15-->
<com.scwang.wave.MultiWaveHeader
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mwhCloseColor="@color/colorAccent"
app:mwhColorAlpha="0.95"
app:mwhProgress="1"
app:mwhStartColor="@color/colorAccent"
app:mwhWaves="
220,0,1,0.1,200" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_alignParentBottom="true">
<TextView
android:id="@+id/tv_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:drawableLeft="@mipmap/fanhui"
android:drawablePadding="6dp"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:textColor="@color/colorBlack"
android:textSize="16sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
android:textColor="@color/colorWhite"
android:textSize="18sp" />
</RelativeLayout>
<TextView
android:id="@+id/tv_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:drawablePadding="6dp"
android:drawableRight="@mipmap/fanhui"
android:ellipsize="end"
android:gravity="center"
android:lines="1"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:text="返回"
android:textColor="@color/colorBlack"
android:textSize="16sp"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
于是就大工告成了
demo连接地址:https://download.youkuaiyun.com/download/loocanp/10697488