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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:25:44+00:00 2026-05-31T11:25:44+00:00

I have some kind ListView. All items in it are in rectangle shape, but

  • 0

I have some kind ListView. All items in it are in rectangle shape, but the top one has round corners as shown in this photo. To create it I’ve cut the top stripe with corners and saved it as item_bg_white_top image and a stripe with 1px height saved as item_bg_white_line image. And this is how I’ve constructed it.

I want to make flash effect when clicking on ltest layout just like clicking on ListView item.

How I can do this?

I’ve tried the code below on ltest but it it didn’t helped. When I tried this code on ltest_inner it just changed its background to black.

final LinearLayout ll = (LinearLayout)findViewById(R.id.ltest);     
    ll.setOnClickListener(new View.OnClickListener() {         
        public void onClick(View v) {               
            ll.setBackgroundResource(android.R.drawable.list_selector_background);               
        }
    });

item.xml

<?xml version="1.0" encoding="utf-8"?>
            <LinearLayout
                android:id="@+id/ltest"
                android:layout_width="300dp"
                android:layout_height="33dp" 
                android:orientation="vertical">

                <LinearLayout
                    android:id="@+id/ltest_inner"
                    android:layout_width="300dp"
                    android:layout_height="8dp"                  
                    android:background="@drawable/item_bg_white_top" />

                <LinearLayout
                    android:layout_width="300dp"
                    android:layout_height="25dp" 
                    android:background="@drawable/item_bg_white_line_repeat" >
                </LinearLayout>
            </LinearLayout>

item_bg_white_line_repeat.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/item_bg_white_line"
    android:tileMode="repeat" />
  • 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-31T11:25:45+00:00Added an answer on May 31, 2026 at 11:25 am

    What you want to do is set up a selector and use it as the drawable for the background.

    Create an xml file in your drawable folder and add a selector to it:

    <?xml version="1.0" encoding="utf-8"?>
          <selector xmlns:android="http://schemas.android.com/apk/res/android">
              <item android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/disabled_pressed_image" />
              <item android:state_enabled="false" android:state_focused="true" android:drawable="@drawable/enabled_focused_image" />
              <item android:state_enabled="false" android:drawable="@drawable/enabled_image" />
              <item android:state_focused="true" android:drawable="@drawable/focused_image" />
              <item android:state_pressed="true" android:drawable="@drawable/pressed_image" />
              <item android:drawable="@drawable/default_image" />
    </selector>
    

    The drawables above reference images also in your drawable folder. You don’t have to implement all the states. Those are just some possible combinations.

    Then attach this as the background to your Linear Layout:

    <LinearLayout
        android:id="@+id/ltest"
        android:layout_width="300dp"
        android:layout_height="33dp" 
        android:background="@drawable/selector_file_name"
        android:orientation="vertical">
    

    where selector file name is simply the name you gave to the selector xml file I mentioned above.

    Also consider removing the inner LinearLayouts. You can do what you are trying to do with a 9-patch, then you’ll only have the one LinearLayout (which you could just change to an ImageView if it is not going to host other Views).

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

Sidebar

Related Questions

I want to have some kind of bounce effect in my animation plugin but
I have some kind of test data and want to create a unit test
I have some kind of problem with jQuery selectors. Let's say i want to
Most program languages have some kind of exception handling; some languages have return codes,
I want to have some kind of single list that is initialized in a
Is it possible in Eclipse to have some kind of packages (sets of projects)
Is there a way to have some kind of default constructor (like a C++
I have a question about reflection I am trying to have some kind of
I have only installed Ruby1.9 on my machine. Have some kind of problems with
Here's a problem. Developers have some kind of a task (develop certain feature), which

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.