关于自定义SeekBar写法以及seekbar不显示的问题
2017-01-04 16:32
471 查看
最近写seekbar的时候突然遇到一个问题,就是内容都设置好了但是就是不显示,界面上空空的,初始代码如下
<SeekBar android:id="@+id/playbar_sb_quick_player_bar" style="@style/seekbar_style" android:layout_width="match_parent" android:layout_height="6dp"/>style文件seekbar_style布局如下,thumb是seekbar的滑块,因为滑块会被覆盖一部分,thumbOffset是设置滑块的左边距,使其不被覆盖
<style name="seekbar_style" parent="@android:style/Widget.SeekBar"> <item name="android:indeterminateOnly">false</item> <item name="android:minHeight">@dimen/y6</item> <item name="android:maxHeight">@dimen/y6</item> <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item> <item name="android:progressDrawable">@drawable/seekbar_horizontal</item> <item name="android:thumb">@drawable/f_playing_point</item> <item name="android:thumbOffset">2.0dp</item> </style>其中seekbar_horizontal.xml文件布局如下
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/bg"> </item> <item android:id="@android:id/secondaryProgress"> <clip> <shape> <corners android:radius="2.0dip"/> <gradient android:angle="270.0" android:centerColor="#a5a5a5" android:centerY="0.5" android:endColor="#a5a5a5" android:startColor="#a5a5a5"/> </shape> </clip> </item> <item android:id="@android:id/progress"> <clip> <shape> <corners android:radius="2.0dip"/> <gradient android:angle="270.0" android:centerColor="#fa8100" android:centerY="0.5" android:endColor="#fa8100" android:startColor="#fa8100" /> </shape> </clip> </item> </layer-list>此处的gra是渐变的shape,startColor,centerColor,endColor分别是初始,中间,结束颜色,此处为了方便都设置为一种颜色至此,自定义seekbar圆满结束,但是运行的时候发现seekbar没有显示排查发现是因为seekbar的height设置了具体的大小6dp导致的,应该是
<SeekBarstyle="@style/seekbar_style"android:layout_width="match_parent"android:layout_height="wrap_content"/>解决问题
相关文章推荐
- winform异型不规则界面设计的实现方法
- 在ASP.NET 2.0中操作数据之二十:定制数据修改界面
- Android中设置只有程序第一次运行才显示的界面实现思路
- hta 实现的五子棋界面
- android开发之欢迎界面的小例子
- Android实现闪屏及注册和登录界面之间的切换效果
- C#中载入界面的常用方法
- bootstrap快速制作后台界面
- Android绘制炫酷引导界面
- android编程实现局部界面动态切换的方法
- Android实现界面左右滑动切换功能
- Android判断现在所处界面是否为home主桌面的方法
- Android用户注册界面
- Android编程实现泡泡聊天界面实例详解(附源码)
- android 引导界面的实现方法
- Android跳转到系统联系人及拨号或短信界面
- ViewPager 与 Fragment相结合实现微信界面实例代码
- 微信js-sdk界面操作接口用法示例
- Android仿新浪微博个人信息界面及其他效果