Android SlidingDrawer 处理程序的图像

发布于 2024-12-28 16:51:48 字数 133 浏览 3 评论 0原文

我想使用我自己的图像作为处理程序的图像。

在此处输入图像描述

如何将默认处理程序图像更改为其他图像? 谢谢, 埃亚尔。

I'd like to use my own image as handler's image.

enter image description here

How can i change the default handler image to onther image?
Thanks,
Eyal.

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

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

发布评论

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

评论(3

芯好空 2025-01-04 16:51:48

您可以使用 ImageViewsrc 指向您的图像作为句柄:

<SlidingDrawer
     android:id="@+id/drawer"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"

     android:handle="@+id/handle"
     android:content="@+id/content">

     <ImageView
         android:id="@id/handle"
         android:src="@drawable/my_image"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent" />

     ....

</SlidingDrawer>

您可能希望将该图像转换为 9patch,以便可以拉伸它以填充窗户。

You can use an ImageView with src pointing to your image as the handle:

<SlidingDrawer
     android:id="@+id/drawer"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"

     android:handle="@+id/handle"
     android:content="@+id/content">

     <ImageView
         android:id="@id/handle"
         android:src="@drawable/my_image"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent" />

     ....

</SlidingDrawer>

You will probably want to convert that image to a 9patch so it can be stretched to fill the height of the window.

孤独岁月 2025-01-04 16:51:48

您应该使用滑块按钮的选择器,以便您可以为不同的状态(聚焦、非聚焦等...)提供不同的图像

<?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/focused" />
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/focusedpressed" />
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pressed" />
    <item android:drawable="@drawable/defaultbutton" />
</selector>

you should use a selector for the slider button so that you can have different images for different states(focussed,non focussed etc...)

<?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/focused" />
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/focusedpressed" />
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/pressed" />
    <item android:drawable="@drawable/defaultbutton" />
</selector>
执妄 2025-01-04 16:51:48

将背景图像添加到 SlidingDrawer 的按钮。

adding background image to the SlidingDrawer's button.

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