如何自定义Android的一个搜索栏的外观?自定义、外观、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...

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

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结帐的绘制文件夹)。这里的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.