3

I am developing an android app with design.

http://prntscr.com/86wnmm

Here the default icon indicator of exapandablelistview is show in left side. How can I show this icon indicator at right side of the listview?, is there any change in Xml file can implement this?

my xml code is

`

<ExpandableListView
    android:id="@+id/expandableListView"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:indicatorRight="?android:attr/expandableListPreferredItemIndicatorRight"
    android:dividerHeight="0.7dp" />

`

salih kallai
  • 879
  • 2
  • 13
  • 34
jasil
  • 79
  • 1
  • 2
  • 11
  • try http://developer.android.com/reference/android/widget/ExpandableListView.html#attr_android:indicatorRight – Bhargav Aug 21 '15 at 05:22

5 Answers5

10

It's too easy to do... Just Follow two steps:

1.)

Just need to add this line in your ExpandableListView xml file.

          android:layoutDirection="rtl"

2.)Then, in your list item.xml or whatever you named it place these 2 more lines...

    android:gravity="left"
    android:layoutDirection="ltr"

Here you go, The Show is Over!! Just Run it..:)

0

use below override method with setIndicatorBoundsRelative methods it works for me for lower version below gellybean use setIndicatorBounds method .

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    // TODO Auto-generated method stub
    super.onWindowFocusChanged(hasFocus);
      mExpandableListView.setIndicatorBoundsRelative(mExpandableListView.getRight()- 40, mExpandableListView.getWidth());

}
Gopal Sharma
  • 300
  • 4
  • 14
0

Yes working solution for all devices is get Width of expandable list and setIndicatorBound to the right.

Override the below method in your Activity containing Expandable list view.

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
mExpandableListView.setIndicatorBounds(mExpandableListView.getRight()- 40, mExpandableListView.getWidth());
} 

this will be helpful surely.

Deepak
  • 34
  • 1
  • 5
0
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
        expandableListView.setIndicatorBounds(expandableListView.getWidth()-40,expandableListView.getWidth());
    } else {
        expandableListView.setIndicatorBoundsRelative(expandableListView.getWidth()-40,expandableListView.getWidth());
    }
}
AnupamChugh
  • 1,779
  • 1
  • 25
  • 36
-2

android:indicatorLeft in <ExpandableListView/> tag xml

Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
androidbear
  • 9
  • 1
  • 4