Android实现波浪线效果(xml bitmap)

2019-12-10 19:23:32于丽

2、自定义控件绘制

     这个方法的确可以达到不错的效果,但是实现比较麻烦。我也看到有朋友搞过,

3、用xml的bitmap标签实现波浪线效果

      首页要搞一个周期的波浪线,即包括波峰和波谷,如下图所示:

      wave_item:

      Android实现波浪线效果(xml bitmap)

    然后水平方向上平铺,从而实现波浪线效果,代码如下:
wave.xml:

<?xml version="1.0" encoding="utf-8"?> 
<bitmap xmlns:android="http://www.easck.com/apk/res/android" 
  android:antialias="true" 
  android:src="@drawable/wave_item" 
  android:tileMode="repeat" /> 

activity_main.xml

<LinearLayout xmlns:android="http://www.easck.com/apk/res/android" 
  xmlns:tools="http://www.easck.com/tools" 
  android:layout_width="match_parent" 
  android:layout_height="match_parent" 
  android:orientation="vertical" 
  android:paddingBottom="@dimen/activity_vertical_margin" 
  android:paddingTop="@dimen/activity_vertical_margin" > 
 
  <ImageView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/wave" /> 
 
</LinearLayout>

 注意:这个ImageView通过background显示图片,src是显示不了这样的效果的。

希望本文所述对大家学习Android软件编程有所帮助。



注:相关教程知识阅读请移步到Android开发频道。