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 8514917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:00:02+00:00 2026-06-11T05:00:02+00:00

I use a Gallery to display Contacts’s info,on the item view,there has two button

  • 0

I use a Gallery to display Contacts’s info,on the item view,there has two button which i use selector as their background,now here is the problem,i touch the area out of this two button,this two button will change the background seem like they are all pressed.
here is the gallery item

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#505050"
  >
  <ImageView 
    android:id="@+id/phone_contact_image"
    android:layout_height="160dip"
    android:layout_width="160dip"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="25dip"
    android:src="@drawable/contact_phone_image_1"
    />
  <TextView  
    android:id="@+id/phone_contact_name"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:textSize="25dip"
    android:layout_below="@id/phone_contact_image"
    android:layout_marginTop="10dip"
    android:gravity="center_horizontal"
    android:textColor="#FFFFFF"
    />
  <TextView
    android:id="@+id/phone_contact_numbler"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textSize="25dip"
    android:gravity="center_horizontal"
    android:layout_below="@id/phone_contact_name"
    android:text="@string/contact_phone_numbler"
    android:textColor="#FFFFFF"
    />
  <Button 
    android:id="@+id/phone_contact_edit_btn"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="@string/editContact_title_edit"
    android:textSize="28dip"
    android:background="@drawable/btn_button_bg"
    android:layout_marginLeft="30dip"
    android:layout_marginRight="30dip"
    android:layout_marginTop="10dip"
    android:textColor="#FFFFFF"
    android:layout_below="@id/phone_contact_numbler"
    />
  <Button 
    android:id="@+id/phone_contact_call_btn"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:text="@string/title_call_via"
    android:textSize="28dip"
    android:background="@drawable/btn_confirm_bg"
    android:layout_marginTop="20dip"
    android:layout_marginLeft="30dip"
    android:layout_marginRight="30dip"
    android:textColor="#FFFFFF"
    android:layout_below="@id/phone_contact_edit_btn"
    />
</RelativeLayout>

here is the selector

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@drawable/btn_button_focus" />
    <item android:state_pressed="true" android:drawable="@drawable/btn_button_pressed" />
    <item android:drawable="@drawable/btn_button_normal" />
</selector>
  • 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-11T05:00:04+00:00Added an answer on June 11, 2026 at 5:00 am

    you are right. But you didnt mentioned when the state is not pressed or not focused and not selected then what you will do?

    Try this:
    make a styles.xml file in you res.values folder
    and add it.

     <style name="styleNormalButton">
            <item name="android:background">@drawable/backgroundbutton</item>
        </style>
    

    consider the @drawable/backgroundbutton.xml is your selector file and add the below code in that.

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_focused="true" android:drawable="@drawable/btn_button_focus" />
        <item android:state_pressed="true" android:drawable="@drawable/btn_button_pressed"/>
    
        <item android:drawable="@drawable/btn_default_pressed_holo_dark"
          android:state_enabled="false" />
        <item android:drawable="@drawable/btn_button_normal" />
    </selector>
    

    and finally into your layou file.
    set the background of the button to style/styleNormalButton

    hope this will help you

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

Sidebar

Related Questions

Almost all examples of how to use display images from the image gallery are
I have a Gallery, which has an adapter connects to it. In the getView
I'm implementing a custom view where I use ViewFlipper which shows my custom View
I'm looking to use a javascript gallery to display images on mobile devices such
I have a picture gallery and I use fancybox to display pictures, and navigate
How can I use default Android gallery to display only application's photos? Basically I
I have a gallery that I use to display some ImageViews. I'd like to
My app consists of an image gallery. It is a scroll view which displays
I am downloading images from web and i use Gallery widget to display the
We are making an app that includes a digital gallery which display photos and

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.