更改Android的搜索栏吸取的主要进展顶部二次进展如何? [英] Changing Android SeekBar to draw secondary progress on top of primary progress?

查看:166
本文介绍了更改Android的搜索栏吸取的主要进展顶部二次进展如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想换一个机器人搜索栏的行为,使二级Android的搜索栏实际上是画在主要的android搜索栏的顶部。从这里列出的进度文档: <一href="http://developer.android.com/reference/android/widget/ProgressBar.html#attr_android:secondaryProgress" rel="nofollow">http://developer.android.com/reference/android/widget/ProgressBar.html#attr_android:secondaryProgress

I would like to change the behavior of an android seekbar so that the secondary android seekbar is actually drawn on top of the primary android seekbar. From the ProgressBar documentation listed here: http://developer.android.com/reference/android/widget/ProgressBar.html#attr_android:secondaryProgress

这是进步的主要进展和之间绘制   背景。

This progress is drawn between the primary progress and the background.

二次进度条现在的样子:

Current look of secondary Progress bar:

二次进度条所需的外观:

Desired look of secondary progress bar:

在理想情况下,我想覆盖ProgressBar.java在Android的一个方法来改变图纸的顺序,使二次进度条上绘制的主要进度条的顶部,但我已经很难找到合适的区域在源$ C ​​$ C覆盖。任何想法去哪里找?

Ideally I'd like to override a method in ProgressBar.java in Android to change the order of drawing so that the secondary progress bar is drawn on top of the primary progress bar, but I've had difficulty finding the proper area in the source code to override. Any ideas where to look?

我已经成功尝试画两个进度条一个在另一个使用的是相对布局之上,但这种方法需要创建两个控件。

I have had success attempting to draw two progress bars one on top of another using a relative layout, but this approach requires creating two controls.

推荐答案

这是一个迟到的答案,只是我发现了如何做到这一点。并不难:)

This is a late answer, but just I found out how to do this. Not that difficult :)

首先看看如何进步绘制在Android项目[点击这里]中定义。(<一href="https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable/progress_horizontal_holo_dark.xml" rel="nofollow">https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable/progress_horizontal_holo_dark.xml)

First of all look at how the progress drawable is defined in the android project [here].(https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable/progress_horizontal_holo_dark.xml)

所有你需要做的是切换secondaryProgress和进步的秩序,使进度来之前(位于下方)secondaryProgress是这样的:

All you have to do is switch the order of secondaryProgress and progress so that progress comes before (lies below) secondaryProgress like this:

<item android:id="@android:id/background"
      android:drawable="@android:drawable/progress_bg_holo_dark" />

<item android:id="@android:id/progress">
    <scale android:scaleWidth="100%"
           android:drawable="@android:drawable/progress_primary_holo_dark" />
</item>

<item android:id="@android:id/secondaryProgress">
    <scale android:scaleWidth="100%"
           android:drawable="@android:drawable/progress_secondary_holo_dark" />
</item>

现在可悲的是这些资源都是不公开的。所以,你必须复制<一个href="https://raw.github.com/android/platform_frameworks_base/master/core/res/res/drawable-xhdpi/progress_bg_holo_dark.9.png"相对=nofollow> progress_bg_holo_dark.9.png ,<一个href="https://raw.github.com/android/platform_frameworks_base/master/core/res/res/drawable-xhdpi/progress_primary_holo_dark.9.png"相对=nofollow> progress_primary_holo_dark.9.png 和<一href="https://raw.github.com/android/platform_frameworks_base/master/core/res/res/drawable-xhdpi/progress_secondary_holo_dark.9.png"相对=nofollow> progress_secondary_holo_dark.9.png 您的项目绘制-xhdpi文件夹(也许到跟其他dpi的图像,以及)。

Now sadly those resources are not public. So you will have to copy progress_bg_holo_dark.9.png, progress_primary_holo_dark.9.png and progress_secondary_holo_dark.9.png to your projects drawable-xhdpi folder (and maybe to the same with other dpi images as well).

然后调整xml文件像下面的(只是删除安卓):

Then adjust the xml file like the following (just remove "android:"):

<item android:id="@android:id/background"
      android:drawable="@drawable/progress_bg_holo_dark" />

<item android:id="@android:id/progress">
    <scale android:scaleWidth="100%"
           android:drawable="@drawable/progress_primary_holo_dark" />
</item>

<item android:id="@android:id/secondaryProgress">
    <scale android:scaleWidth="100%"
           android:drawable="@drawable/progress_secondary_holo_dark" />
</item>

这篇关于更改Android的搜索栏吸取的主要进展顶部二次进展如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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