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

The Archive Base Latest Questions

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

Hi I have created a relative layout. and align the imageview to the right

  • 0

Hi I have created a relative layout. and align the imageview to the right of relativelayout. I set the background of relativelayout using selector. if i select thye relativelayout its color wil be green otherwise its color will be white. Now I want to set the image depending on the selection of scrollview. If scrollview is selected then i want to show imge1 if not then i want to show image2. How can I achieve this?

main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/selector">
    <ImageView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/arrow_right"

        android:layout_alignParentRight="true" />
</RelativeLayout>

selector.xml

<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_focused="true"
        android:state_pressed="false"
        android:drawable="@drawable/grbk" />
    <item
        android:state_focused="true"
        android:state_pressed="true"
        android:drawable="@drawable/grbk" />
    <item
        android:state_focused="false"
        android:state_pressed="true"
        android:drawable="@drawable/grbk" />
    <item
        android:drawable="@drawable/whbk" />
</selector>

Thanks
Sunilenter image description here

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

    We can create another selector for imageview and pass that selector as background to imageview.

    imageselector.xml

    <selector
        xmlns:android="http://schemas.android.com/apk/res/android">
        <item
            android:state_focused="true"
            android:state_pressed="false"
            android:drawable="@drawable/arow_selected" />
        <item
            android:state_focused="true"
            android:state_pressed="true"
            android:drawable="@drawable/arow_selected" />
        <item
            android:state_focused="false"
            android:state_pressed="true"
            android:drawable="@drawable/arow_selected" />
        <item
            android:drawable="@drawable/arow_unselect" />
    </selector>
    

    main.xml

            <ImageView
            android:id="@+id/arrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/imageselector"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="20dip"/>
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have extended a RelativeLayout with all its constructor.And I have created a layout
I have imageView inside a relative layout. And when i create the activity i
I have created a Layout using ExtJs. It consists of a left menu and
I have created a custom view by extending Relative Layout and it looks like
I have created this web form using absolute positioning instead of relative. As expected
I have a relative layout that has an ImageView and and a textview aligned
I have created following layout.which has two relative layouts and one scrollview ,following code
I have programatically created a set of ImageButton views (with transparent background) as map
I have created a mac application using the WebView. But issue is that webView
I have created my entire website by using a main table, and having the

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.