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 8941581

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:20:20+00:00 2026-06-15T11:20:20+00:00

So. You know how when you click a post in the Google+ app, the

  • 0

So. You know how when you click a post in the Google+ app, the entire View becomes blue. I want to do that as well, but with an ImageView.

I have the following code snippet, setting the actual image as the background and the selector as the main resource. This looks good, but doesn’t respect scaleType for the background image:

      <ImageView
            android:id="@+id/painting_image"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@drawable/img"
            android:src="@drawable/selector"
            android:scaleType="centerCrop" />

By the way, @drawable/selector is just a selector that shows a tranparent color for state_pressed:

<item android:state_pressed="true">
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#44521400" />
    </shape></item>

How can I make this work while respecting the scaleType?

  • 0 0 Answers
  • 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-15T11:20:21+00:00Added an answer on June 15, 2026 at 11:20 am

    Wrap your ImageView in a FrameLayout, and define the FrameLayout to be clickable. Be careful to assign the onClick event to the FrameLayout, and not to the ImageView, or the effect will break! Also note that foreground has been set to a selector, not background.

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:clickable="true"
            android:foreground="@drawable/imagebutton_selector" >
    
            <ImageView
                android:id="@+id/painting_image"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:scaleType="centerCrop" />
    
        </FrameLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know that can mouse click event detects colors or even strings.
I have a Delphi 6 app that embeds the Chromium web browser. I want
you all know: right click -> zoom in or out in flash file, well,
I have this code : jQuery('#btSave').click(function (event) { var jqxhr = $.post(Controller/Action, { lastName:
I have this code right here: $('#add_club_button').click(function(){ $('#add_club_button_ajax').show(); $.post('<?php echo base_url()?>addClub/save',$('#add_club_form').serialize(),function(data){ if(data == 'OK'){
I don't know if I've even asked the question properly, but I have a
I have a post & request. I need when user on post page click
I know there are similar post to this but I couldn't find my answer
I have a Google Maps project, and I want to do an array to
Does anyone know why this isn't working? $(.v1).click(function(){ $.post(inc.php?action=vote&id=$(this).attr('id')&vote=1); }); $(.v2).click(function(){ $.post(inc.php?action=vote&id=$(this).attr('id')&vote=2); }); Thanks,

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.