android seekBar改变样式-非圆角的实现

android seekBar默认的效果是圆角的,如果想实现非圆角的,可以试下下面这种方式:

首先布局文件的实现方式:

<?xml version= "1.0" encoding= "utf-8" ?>
<LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android"
     android:layout_width= "fill_parent"
     android:layout_height= "fill_parent"
     android:orientation= "vertical" >
 
     <RelativeLayout
         android:layout_width= "match_parent"
         android:layout_height= "wrap_content"
         android:layout_marginBottom= "50dip" >
 
         <ImageView
             android:layout_width= "fill_parent"
             android:layout_height= "26dip"
             android:layout_centerVertical= "true"
             android:background= "@drawable/seekbar_bg" >
         </ImageView>
 
         <SeekBar
             android:id= "@+id/seekBar1"
             android:layout_width= "match_parent"
             android:layout_height= "wrap_content"
             android:layout_marginLeft= "4dip"
             android:layout_marginRight= "4dip"
             android:layout_marginTop= "3dip"
             android:max= "100"
             android:progress= "75"
             android:progressDrawable= "@drawable/seekbar_img1"
             android:thumb= "@null" />
     </RelativeLayout>
 
</LinearLayout
其次需要准备非圆角的图片,然后写seekbar的style文件,如下所示:

<layer-list xmlns:android= "http://schemas.android.com/apk/res/android" >
 
     <item
         android:id= "@android:id/background"
         android:drawable= "@drawable/seek_color_drawable_bg_translucent_print" >
         <!--
     <shape >
 
             <corners android:radius= "0dip" />
 
             <gradient
                 android:angle= "270"
                 android:centerColor= "#84badc"
                 android:centerY= "0.8"
                 android:endColor= "#85badd"
                 android:startColor= "#5b859e" />
         </shape>
 
         -->
     </item>
 
     <item android:id= "@android:id/progress" >
<clip >
 
             <shape >
 
                 <corners android:radius= "0dip" />
 
                 <gradient
                     android:angle= "270"
                     android:centerColor= "#5ea500"
                     android:centerY= "0.75"
                     android:endColor= "#a9eb2f"
                     android:startColor= "#b4f43f" />
             </shape>
         </clip></item>
 
</layer-list>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值