【Android】边框旁的文字实现模糊效果

阅读: 评论:0

【Android】边框旁的文字实现模糊效果

【Android】边框旁的文字实现模糊效果

【问题】

如何实现几行文字的最上面1行和最下面1行的文字为渐变模糊的效果;

【效果图】


【思路】

简单来说:用一个渐变的透明的View来覆盖两边的文字区域;
具体来说:(这里只考虑[区域2])最外面使用 RelativeLayout,里面的文字内容使用 ListView,上面和下面的模糊效果,使用背景为渐变的 View,(这个View没有任何内容,只是用来覆盖里面的文字)。

【代码】

设置两个颜色用在后面的渐变中

     <color name="rryt_bg_vc_scanning_color_1">#f0ffffff</color>    <color name="rryt_bg_vc_scanning_color_2">#11ffffff</color>

顶部的渐变(res/drawable/rlyt_bg_vc_scanning_l)

 <?xml version="1.0" encoding="utf-8"?><shape xmlns:android="" >    <gradient        android:angle="90"        android:endColor="@color/bg_color_1"        android:startColor="@color/bg_color_2"        android:type="linear" /></shape>

底部的渐变(res/drawable/rlyt_bg_vc_scanning_l)

 <?xml version="1.0" encoding="utf-8"?><shape xmlns:android="" >    <gradient        android:angle="90"        android:endColor="@color/bg_color_2"        android:startColor="@color/bg_color_1"        android:type="linear" /></shape>

布局里面实现

 <RelativeLayout    android:layout_width="match_parent"    android:layout_height="match_parent" >    <ListView       android:id="@+id/lv_vc_scanning_device"       android:layout_width="match_parent"       android:layout_height="wrap_content" />     <View        android:layout_width="match_parent"        android:layout_height="32dp"        android:background="@drawable/rlyt_bg_vc_scanning_device_top"        android:layout_alignParentTop="true"/>     <View        android:layout_width="match_parent"        android:layout_height="32dp"        android:background="@drawable/rlyt_bg_vc_scanning_device_bottom"        android:layout_alignParentBottom="true"/></RelativeLayout>

本文发布于:2024-02-01 01:48:02,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170672328232976.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:边框   模糊   效果   文字   Android
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23