Expandable Listview SetIndicatorBounds are not working in my project code.
Here is my Layout:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|center_vertical"
android:weightSum="1.0"
>
<ExpandableListView
android:id="@+id/custom_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:dividerHeight="1dp"
android:layout_weight="1"
android:paddingBottom="0dp"
android:divider="#b5b5b5"
/>
</LinearLayout>
Here is my code :
lv1 = (ExpandableListView) findViewById(R.id.custom_list);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
lv1.setIndicatorBounds(width - GetPixelFromDips(50), width - GetPixelFromDips(10));
public int GetPixelFromDips(float pixels) {
// Get the screen's density scale
final float scale = getResources().getDisplayMetrics().density;
// Convert the dps to pixels, based on density scale
return (int) (pixels * scale + 0.5f);
}
My Moto G kitkat device width is 720 . But setIndicatorBounds did not seems to be worked out in my Kitkat device .
Any help will be appreciated.
Thanks,
try this:
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
mListView.setIndicatorBounds(myLeft, myRight);
} else {
mListView.setIndicatorBoundsRelative(myLeft, myRight);
}
reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With