如何添加Android的搜索栏里面的数字规模有多大? [英] How to add number scale inside android seekbar?
问题描述
我用自定义尝试搜索栏里面有数量规模,但不工作。这个搜索栏必须支持所有的屏幕分辨率。我怎样才能让这个样子。请给出您宝贵的想法。
I'm trying with the custom seekbar inside have number scale, But is not working. This seekbar must support all screen resolutions. how can i make like this. Please give your valuable idea.
我custom_seekbar.xml
My custom_seekbar.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/unselect"/>
<item
android:id="@android:id/secondaryProgress"
android:drawable="@drawable/select">
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/select">
</item>
activity_main.xml中
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_screen_bg"
android:orientation="vertical"
tools:context=".MainActivity" >
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:indeterminate="false"
android:max="10"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:progressDrawable="@drawable/custom_seekbar" />
</LinearLayout>
Unselesct.png
Unselesct.png
select.png
select.png
myresult屏幕像这样
myresult screen like this
我期待这样的
推荐答案
有数量解决问题的方法:
There's number to solutions to the problem:
- 使用为backgorund 9patch 图像(这基本上应的用作背景搜索栏)。如下所示:
- Use 9patch image for backgorund (which is basically should be used as background for seekbar). Like the following:
(名称应为 unselect_patch.9.png
),并稍微修改 custom_seekbar.xml
来如下所示:
(name should be unselect_patch.9.png
) and slightly modify custom_seekbar.xml
to look like the following:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/background"
android:drawable="@drawable/unselect_patch"/>
<item android:id="@android:id/secondaryProgress">
<clip>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/select"
android:tileMode="disabled" />
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/select"
android:tileMode="disabled" />
</clip>
</item>
</layer-list>
- 就在布局提供图像的确切大小(例如
layout_width =@扪/ select_image_width
);
- Just provide exact size of the image in layout (e.g.
layout_width="@dimen/select_image_width"
);
要支持所有决议案 - 为不同分辨率提供图像,rel=\"nofollow\">支持多种屏幕中。相同的图像将无法正常工作的所有决议和这里的好只是按照上面的链接中详细描述的最佳做法。
To support all resolutions - provide images for different resolutions, as described in Supporting Multiple Screens. The same images will not work fine for all resolutions and here's better just follow best practices described in detail at the link above.
这篇关于如何添加Android的搜索栏里面的数字规模有多大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!