Extendable title height of view list indicator?

I have an expandable list with a group indicator to the right of the list, in this I called the name of the name one line, my conclusion is like this

enter image description here

in the image above, my indicator looks good. in the bottom image my indicator does not look very good why this is happening

enter image description here

here is my code

    mExpandableList = (ExpandableListView)findViewById(R.id.expandable_list);
    mExpandableList.setIndicatorBounds(width - GetPixelFromDips(40), width - GetPixelFromDips(10)); 

xml

     <ExpandableListView
    android:id="@+id/expandable_list"        
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:groupIndicator="@drawable/group_indicator" />

group_indicator.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:drawable="@drawable/arrow_down"     android:state_expanded="true"/>
    <item android:drawable="@drawable/arrow_up"/>
</selector>

Does anyone have an idea to help this ........

+5
source share
4 answers

I solve this problem in a more complex way, but it works:

Fragment of an extensible list layout file:

<ExpandableListView
  android:id="@+id/accordion"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:groupIndicator="@android:color/transparent"
  android:scrollbars="none" >
</ExpandableListView>

Layout for list item

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/accordion_main_background"
    android:minHeight="50dip"
    android:orientation="vertical"
    android:padding="@dimen/screenPromoTaskRootPadding" >

    <TextView
        android:id="@+id/accordionTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginRight="10dip"
        android:layout_toLeftOf="@+id/accordionIndicator"
        android:background="@color/accordionOrangeBackColor"
        android:paddingLeft="2dip"
        android:paddingRight="2dip"
        android:textColor="@color/blackTextColor"
        android:textSize="@dimen/accordMainTextSize" />

    <ImageView
        android:id="@+id/accordionIndicator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:src="@drawable/arrow_up_np" />

</RelativeLayout>

. adaptDataCollection , ExpandableListAdapter. , , .

ExpandableListView accordion = (ExpandableListView) findViewById(R.id.accordion);
accordion.setOnGroupClickListener(this);

@Override
public boolean onGroupClick(ExpandableListView paramExpandableListView, View paramView, int paramInt, long paramLong) {
    ImageView icon=(ImageView)paramView.findViewById(R.id.accordionIndicator);
    for (int i = 0; i < adapterDataCollection.size(); i++) {
        if (i == paramInt) {
            if (paramExpandableListView.isGroupExpanded(i)) {
                paramExpandableListView.collapseGroup(i);
                icon.setImageResource(R.drawable.arrow_up_np);
            } else {
                paramExpandableListView.expandGroup(i);
                icon.setImageResource(R.drawable.arrow_down_np);
            }
        } else {
            paramExpandableListView.collapseGroup(i);
            icon.setImageResource(R.drawable.arrow_up_np);
        }
    }
    paramExpandableListView.invalidate();
    return true;
}
+2

[layer-list] http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:bottom="2dp"
        android:drawable="@drawable/shrink"
        android:top="2dp"/>

</layer-list>

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/layer_shrink" android:state_expanded="true"/>
+1

9 - . .

right_arrow_9_patch_image

down_arrow_9_patch_image

".9" , " your_image_name.9.png"

+1

, custom_group_layout.xml, getGroupView() . , , fill_parent, , .

Example

0
source

All Articles