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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:04:21+00:00 2026-06-01T22:04:21+00:00

I would like to create a linear layout which would behave similarly to ImageButton.

  • 0

I would like to create a linear layout which would behave similarly to ImageButton.

<LinearLayout
    android:id="@+id/container"
    style="?WidgetHomeIconContainer">            

    <ImageView
        android:id="@+id/icon"
        style="?WidgetHomeIcon" />

    <TextView
        android:id="@+id/title"
        style="?WidgetHomeLabel"             
        android:text="@string/title"
        android:textAppearance="?attr/TextHomeLabel" />
</LinearLayout>

In styles of ImageView, TextView and LinearLayout, I set a selectors for all states.

Now:

  • when I click on ImageView (I tried it also with ImageButton) – it behaves correctly and the image is changed according the selector xml.
  • when I click on LinearLayout – the linear layout is clicked, but the the ImageView and TextView don’t change it’s drawable/appearance

So I would like to do the following. When I click on parent LinearLayout, I need to change all it’s childs to pressed state.

I tried to add following code to LinearLayout onClickListener to propagate the click:

@Override
public void onClick(View v)
{
    LinearLayout l = (LinearLayout) v;
    for(int i = 0; i < l.getChildCount(); i++)
    {
        l.getChildAt(i).setClickable(true);
        l.getChildAt(i).performClick();
    }
}

But it still reamins the same. Thank you very much for any help.

  • 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-01T22:04:22+00:00Added an answer on June 1, 2026 at 10:04 pm

    Put

    android:duplicateParentState="true"
    

    in your ImageView and TextView..then the views get its drawable state (focused, pressed, etc.) from its direct parent rather than from itself.

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

Sidebar

Related Questions

I would like to create a class MyView, which extends LinearLayout. MyView has a
Given a horizontal LinearLayout in Android, I'd like to create: (1) a textbox which
I would like to create an array of LinearLayout s. In my application I
i would like create a array of structure which have a dynamic array :
I would like to create a database backed interactive AJAX webapp which has a
So I would like to add a custom imageview to a ProgressDialog: LinearLayout root
I would like to create a customized popup dialog which contains a spinner. The
I would like to create an custom View on Android. I have tried to
On Android, I would like to create a button that contains some other Views.
I would like to create a CustomButton which has a predefined onClick . In

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.