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.

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?
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:
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”.