2013-04-24 7 views
5

は、私はタイトル名を持つこの中で、リストの右側に表示され、私のインジケータが良い探している上記の画像では、この拡張可能なリストビューインジケータの表示タイトルの高さ?私はグループの指標で拡張可能なリストビューを使用している

enter image description here

のように私の出力単線です。下の画像に私のインジケータは、それが拡大していない格好良い 、なぜこのここ

enter image description here

が私のコードで起こる

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> 

いずれかが、あなたのadapterClassのgetGroupView()あなたにそれを膨らませるときに、この1 ........

+0

グループ項目のレイアウトはどちらですか? – AlexBcn

+0

@AlexBcn linearlayout ......... – NagarjunaReddy

答えて

0

はあなたがあなたのcustom_group_layout.xmlで使用しているビューを見てアイデアの助けを持っています。あなたのインジケーターの表示には、おそらくfill_parentがあります。そのため、グループに複数のテキスト行が含まれていると、アイテムがアイコンを伸ばしているのです。

An example

2

私は、より複雑な方法この問題を解決するが、それは動作します:リスト族元素

<?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> 
ため

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

レイアウト:拡張可能なリストとレイアウトファイルの

断片

とアクティビティadaptedDataCollectionは、単にExpandableListAdapterのデータを含むListでした。また、それはアコーディオンの実装の断片であるので、リストグループは選択された後に他の要素を崩壊させます。

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; 
} 
1

あなたは[レイヤーリスト]でインジケーターの高さを設定することができ ​​

<?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

とダウンのためにあなたがドンの `tは "your_image_name.9のようなイメージ名に" 0.9" を追加するを忘れて画像

down_arrow_9_patch_image

下に使用することができます矢印。png "

関連する問題