Android:自定义微调器帮助

发布于 2024-11-27 21:21:34 字数 1477 浏览 0 评论 0原文

我正在关注关于如何创建自定义微调器的教程。在开头附近,它指示您导航到: *android.jar\res\drawable-finger* 但由于某种原因,我在 android.jar 中找不到“drawable-finger”文件夹。我认为这可能与API级别有关,所以我将其从1.6更改为2.1,但无济于事。我解决了这个问题,并将它们放入可绘制文件夹中,认为我可以解决它,但然后旋转器使图像拉伸并变形,而不是在 x 方向重复图像。有什么想法吗?

谢谢!

编辑:这是代码 微调器

    <Spinner android:id="@+id/catspinner" android:layout_marginLeft="15dip" android:layout_marginRight="15dip"
 android:layout_width="fill_parent" android:layout_centerHorizontal="true"
 android:layout_height="wrap_content" android:layout_centerVertical="true"
 android:drawSelectorOnTop="true" android:background="@drawable/spinnerbackground"/>   

微调器背景的

    <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" 
          android:state_pressed="false" 
          android:drawable="@drawable/myspinner_select" />
    <item android:state_focused="true" 
          android:state_pressed="true"
          android:drawable="@drawable/myspinner_press" />
    <item android:state_focused="false" 
          android:state_pressed="true"
      android:drawable="@drawable/myspinner_press" />
    <item android:drawable="@drawable/myspinner_normal" />
</selector>

代码:看起来像这样在此处输入图像描述

I am following this tutorial on how to create custom spinners. Near the begining it instructs you to navigate to: *android.jar\res\drawable-finger* But for some reason I can't find the "drawable-finger" folder in my android.jar. I thought it may have to do with the API level so I changed it from 1.6 to 2.1 to no avail. I went around this and put them in the drawable folder thinking I could just work around it but then the spinner has the image stretched and malformed instead of repeating the image in the x direction. Any ideas?

Thanks!

EDIT: Here is the code
Spinner

    <Spinner android:id="@+id/catspinner" android:layout_marginLeft="15dip" android:layout_marginRight="15dip"
 android:layout_width="fill_parent" android:layout_centerHorizontal="true"
 android:layout_height="wrap_content" android:layout_centerVertical="true"
 android:drawSelectorOnTop="true" android:background="@drawable/spinnerbackground"/>   

code for the spinner background:

    <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" 
          android:state_pressed="false" 
          android:drawable="@drawable/myspinner_select" />
    <item android:state_focused="true" 
          android:state_pressed="true"
          android:drawable="@drawable/myspinner_press" />
    <item android:state_focused="false" 
          android:state_pressed="true"
      android:drawable="@drawable/myspinner_press" />
    <item android:drawable="@drawable/myspinner_normal" />
</selector>

it looks like thisenter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

霞映澄塘 2024-12-04 21:21:34

谢里夫是对的。就遵循本教程而言,它不会(也不应该)建议您将图像放回 android.jar/res/drawable-finger 中。您应该将这些图像的版本放在 drawable 文件夹中(即 drawable-ldpidrawable-mdpi 等)。

我怀疑图像被拉伸且不重复的问题是您的代码或图像的结果,而不是您放置图像的位置。您可以发布您的代码,我们也许可以提供帮助。

我还注意到该教程看起来像是基于预发布的 Android SDK 版本。我猜 drawable-finger 文件夹不再存在。本教程的其他元素也可能已经过时。

Sherif is correct. As far as following the tutorial, it doesn't (and shouldn't) suggest that you put the images back in android.jar/res/drawable-finger. You should put your versions of those images in your drawable folders (i.e. drawable-ldpi, drawable-mdpi, etc).

I suspect that the issue with the image being stretched and not repeated is a result of your code or image, not the location you put the images. You could post your code and we might be able to help with that.

I also noticed that the tutorial looks like it is based off of a pre-release Android SDK version. I'm guessing that the drawable-finger folder no longer exists. It's also possible that other elements of the tutorial are outdated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文