Android开发简单易用的音乐频谱效果

来源:互联网 发布:扫描文字的软件 编辑:程序博客网 时间:2024/06/05 20:14

先贴个图看看效果



使用说明:

首先添加依赖
  1. dependencies {
  2.   compile 'com.taishi-y:musicindicator:0.1.0'
  3. }

XML

  1. <com.taishi.library.Indicator
  2.       android:id="@+id/indicator"
  3.       android:layout_width="match_parent"
  4.       android:layout_height="180dp"
  5.       android:layout_alignParentTop="true"
  6.       android:background="#000000"
  7.       app:bar_num="50"
  8.       app:bar_color="#1DD069"
  9.       app:step_num="70"
  10.       app:duration="20000"
  11.       />

Sample

1 - Normal Music Indicator


  1. <com.taishi.library.Indicator
  2.       android:id="@+id/indicator"
  3.       android:layout_width="match_parent"
  4.       android:layout_height="180dp"
  5.       android:layout_alignParentTop="true"
  6.       android:background="#000000"
  7.       app:bar_num="50"
  8.       app:bar_color="#1DD069"
  9.       app:step_num="70"
  10.       app:duration="20000"
  11.       />
2 - Google Music Like


  1.   <RelativeLayout
  2.           android:layout_width="wrap_content"
  3.           android:layout_height="wrap_content"
  4.           android:layout_margin="10dp"
  5.           android:background="@drawable/circle">
  6.           <com.taishi.library.Indicator
  7.               android:layout_width="50dp"
  8.               android:layout_height="50dp"
  9.               android:layout_margin="20dp"
  10.               app:bar_num="3"
  11.               app:bar_color="#fff"
  12.               app:step_num="10"
  13.               app:duration="3000"/>
  14.       </RelativeLayout>
  1. <shape xmlns:android="http://schemas.android.com/apk/res/android"
  2.        android:shape="oval">
  3.     <solid
  4.         android:color="#48b3ff"/>
  5. </shape>