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

  • Home
  • SEARCH
  • 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 7954901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:34:25+00:00 2026-06-04T03:34:25+00:00

I have an expandablelistview and I have put a background for the groups item,

  • 0

I have an expandablelistview and I have put a background for the groups item, but I would like to adjust the height. I have already set the height into xml file (50dp) but it doesn’t works (the real height isn’t 50 dp, but it’s taller), so I am thinking to do it programmatically.

enter image description here

Here you are a piece of my code to explain it

grouplayout_index.xml

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/LinearLayout_index"
      android:background="@drawable/bg_capitolo_retina"
      android:paddingBottom="10dp"
      android:paddingTop="10dp"
      android:layout_height="50dp"             ---------------------//height = 50 dp
      android:layout_marginTop="10dp"
      android:layout_marginBottom="10dp"
      android:layout_width="match_parent" >

    <ImageView android:id="@+id/freccia_indice" android:src="@drawable/freccia_o"
        android:clickable="false"
        android:layout_height="28dp"
        android:layout_width="28dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="10dp" 
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:paddingLeft="10dp"  />

    <TextView android:id="@+id/tvGroup"  
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="10dp"
        android:paddingLeft="50dp" />
</LinearLayout> 

Index.java

  public class Index extends  ExpandableListActivity {
        .....
           IndexAdapter   mAdapter = new IndexAdapter .....
          explistview.setAdapter(mAdapter);
}

IndexAdapter.java

   public class IndexAdapter  extends BaseExpandableListAdapter{

     ....various methods......
   public View getGroupView(int groupPosition, boolean isExpanded, View  convertView,ViewGroup parent) {

    if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
             convertView =   infalInflater.inflate(R.layout.grouplayout_index, null);

    }      
         TextView textView = (TextView) convertView.findViewById(R.id.tvGroup);
         textView.setTextAppearance(context, R.style.textViewStyleGroup);
         textView.setText("textview");

            /* I have tried this code but it doesn't works.
           LinearLayout ll = (LinearLayout)   convertView.findViewById(R.id.LinearLayout_indice);
           ll.setLayoutParams(new LinearLayout.LayoutParams(30,50));
*/              
   }

Can someone help me, please?

  • 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-04T03:34:26+00:00Added an answer on June 4, 2026 at 3:34 am

    The problem with the extra height is likely the result of the layout_marginTop and layout_marginBottom set on the LinearLayout. A layout like the following may meet your need:

    <?xml version="1.0" encoding="UTF-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout_index"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@drawable/shape_data_background"
    android:paddingBottom="10dp"
    android:paddingTop="10dp" >
    
    <ImageView
        android:id="@+id/freccia_indice"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:paddingLeft="10dp"
        android:src="@drawable/arrow_right" />
    
    <TextView
        android:id="@+id/tvGroup"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:text="textview" />
    
    </LinearLayout>
    

    Unless you have a requirement for rows that are exactly 50dp, it’s usually worked best for me to let the rows in a list view size themselves using layout_height=”wrap_content”.

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

Sidebar

Related Questions

I have the following problem: I would like to change value of ExpandableListView's cell
I have an ExpandableListView with the following set as the style <style name=expendable_list_view> <item
I have an Activity that sets an ExpandableListAdapter for an ExpandableListView. I would like
I have an ExpandableListView (ELV) with the groups having LinearLayout. I have set the
I have an AlertDialog populated by an ExpandableListView. The list itself works perfectly, but
I have a problem with an ExpandableListView in my Android application. I've set a
I have develop ExpandableListView perfectly. In My ExpandableListView five groups are there. load first
I have an ExpandableListView view and I've implemented OnChildClickListener , but I need to
I have to delete child item in my expandablelistview. My attempt was: 1. Data
I'm using ExpandableListView. i have a around 100 groups in the list, and 10-15

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.