Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8382809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:00:45+00:00 2026-06-09T17:00:45+00:00

I have a drawable like this: <selector xmlns:android=http://schemas.android.com/apk/res/android> <item android:state_pressed=true android:state_window_focused=true android:drawable=@drawable/seek_thumb_pressed /> <item

  • 0

I have a drawable like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true"
      android:state_window_focused="true"
      android:drawable="@drawable/seek_thumb_pressed" />

<item android:state_focused="true"
      android:state_window_focused="true"
      android:drawable="@drawable/seek_thumb_selected" />

<item android:state_selected="true"
      android:state_window_focused="true"
      android:drawable="@drawable/seek_thumb_selected" />

<item android:drawable="@drawable/seek_thumb_normal" />

In code, how do I set my Drawable’s specific state? I’d like to set it to the state_pressed=true state.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:00:46+00:00Added an answer on June 9, 2026 at 5:00 pm

    Got it. A comment from here helped: Android : How to update the selector(StateListDrawable) programmatically

    So Drawable.setState() takes an array in integers. These integers represent the state of the drawable. You can pass any ints you want. Once the ints pass in match a an “item” from the state list drawables the drawable draws in that state.

    It makes more sense in code:

    int[] state = new int[] {android.R.attr.state_window_focused, android.R.attr.state_focused};
    minThumb.setState(state);
    

    Notice that my state list drawable has both the state_pressed="true" and android:state_window_focused="true". So I have to pass both of those int values to setState. When I want to clear it, I just minThumb.setState(new int[]{});

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drawable selector(home_button.xml) for a button, like... <selector xmlns:android=http://schemas.android.com/apk/res/android> <item android:state_pressed=false android:drawable=@drawable/blue_button
I have defined a rectangle drawable like this: <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <corners android:radius=4dip/> <solid
I have a RelativeLayout like this: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=horizontal android:layout_width=fill_parent android:layout_height=wrap_content android:layout_marginTop=10dip> <Button android:id=@+id/negativeButton
I have the following layout... <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/bg_generic_portrait>
I have a faux dialog which uses this layout: <?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a picture in res/drawable directory: res/drawable/picture.jpeg. Can I dynamically update this picture.jpeg
I have one ImageButton in my xml layout like that : <ImageButton android:id=@+id/tabsButton android:background=@drawable/button
I have created a button in my screen's XML like this: <Button android:text=Lets Get
Given I have a background drawable to create bulletpoints for TextViews like this: Then
I declare a Android button like this: <Button android:layout_width=fill_parent android:layout_height=wrap_content android:background=@drawable/festival_button_selector android:textColor=@color/white android:text=@string/STR_FEST_SELOFF android:onClick=onBtnFestSelectionClick

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.