如何自定义Android的一个搜索栏的外观? [英] How to customize the look of a SeekBar in Android?

查看:171
本文介绍了如何自定义Android的一个搜索栏的外观?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用搜索栏在我的应用程序,我想将它定义一点点。我已经想出如何修改绘制对象拇指和背景。

I use a SeekBar in my application and I would like to customize it a little bit. I already figured out how to change the Drawable for the thumb and for the background.

我的问题是如何改变的大小搜索栏?如果我只是改变的高度搜索栏这样的,查看只被削去,并且只显示前一块 SeekBar`:

My question is how to change the size of the SeekBar? If I just change the height of the SeekBar like this, theViewis only clipped and it only shows the top piece of theSeekBar`:

<SeekBar
   android:layout_height="10dip"
   style="@style/seekbar_style" />

如何更改的总体规模的搜索栏?我想这是非常薄那么标准搜索栏

How do I change the overall size of the Seekbar? I want it to be much thinner then the standard SeekBar.

推荐答案

我不知道Seekbars,但Progressbars可以使用自定义样式(在styles.xml定义)定制像这样:

I'm not sure about Seekbars, but Progressbars can be customized by using a custom style (defined in your styles.xml) like so:

<style name="MyCustomProgressStyle">
    <item name="android:indeterminateOnly">false</item>
    <item name="android:progressDrawable">@drawable/custom_progress_drawable</item>
    <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
    <item name="android:minHeight">10dip</item>
    <item name="android:maxHeight">10dip</item>
</style>

然后就可以设置基于自定义绘制Android系统的 progress_horizo​​ntal.xml (它在框架/基/核心/ RES /一个 AOSP结帐的绘制文件夹)。这里的<一个href="http://$c$c.google.com/p/android-target/source/browse/trunk/res/drawable/progress_horizontal.xml?r=13">an例如的来自开放源代码项目。

Then you can set up a custom drawable based on the android system's progress_horizontal.xml (it's in the frameworks/base/core/res/drawable folder of an AOSP checkout). Here's an example from an open-source project.

这篇关于如何自定义Android的一个搜索栏的外观?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆