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

  • Home
  • SEARCH
  • 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 4025116
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:48:23+00:00 2026-05-20T10:48:23+00:00

If I set my ImageView to be both clickable and focusable, it works, but

  • 0

If I set my ImageView to be both clickable and focusable, it works, but I have no way to tell which image is focused. What’s the best way to get it to draw an orange border around the view so the user knows it’s currently in focus?

I tried dropping it in a LinearLayout and setting that to be focusable and clickable instead, but didn’t have any luck. Even when I put a margin on it, there’s nothing to indicate that it was selected.

  • 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-05-20T10:48:23+00:00Added an answer on May 20, 2026 at 10:48 am

    You can use a drawable with a selector as the background.

    For example, I have gallery_image_bg.xml in res/drawable:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android"
              android:constantSize="true">
      <item android:state_selected="true">
        <shape android:shape="rectangle">
          <solid android:color="#E6E4E0"/>
          <stroke android:width="3dp" android:color="#F9C11E"/>
          <padding android:left="3dp"
                   android:top="3dp"
                   android:right="3dp"
                   android:bottom="3dp" />
        </shape>
      </item>
      <item android:state_pressed="true">
        <shape android:shape="rectangle">
          <solid android:color="#E6E4E0"/>
          <stroke android:width="3dp" android:color="#F9C11E"/>
          <padding android:left="3dp"
                   android:top="3dp"
                   android:right="3dp"
                   android:bottom="3dp" />
        </shape>
      </item>
      <item>
        <shape android:shape="rectangle">
          <solid android:color="#E6E4E0"/>
          <stroke android:width="3dp" android:color="#FFF"/>
          <padding android:left="3dp"
                   android:top="3dp"
                   android:right="3dp"
                   android:bottom="3dp" />
        </shape>
      </item>
    </selector>
    

    This creates three different-colored 3dp lines around the image. They are visible because the padding forces the image to render in a slightly smaller area.

    Used in code like so:

    image.setBackgroundResource(R.drawable.gallery_image_bg)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set an image for an ImageView using the setImageResource(R.drawable.icon1) . Now my
I have set imageView's frame in table using the following code. cell.imageView.image = [UIImage
I set up 404 handler page in web.config, but it works ONLY when extension
how can we html.fromhtml to load image from web and set into imageview ?
I want to read image from web ex. http://www.abc.com/image1.jpg and dynamic set to imageview
I need to set the ImageView's src within my style, but I cant find
If i have an ImageView that fills the screen. The ImageView background is set
I'm working on a Gingerbread (2.3.3) device. I have an ImageView which contains an
I have written an app which displays the location of a set of traffic
Is there a way to add a pressed state to an ImageView? I have

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.