如何使expandablelistview使用默认扩展右侧/折叠图标指示? [英] How to make expandablelistview with default expand/collapse icon indicator at right?

查看:361
本文介绍了如何使expandablelistview使用默认扩展右侧/折叠图标指示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发与设计的Andr​​oid应用程序。

I am developing an android app with design.

http://prntscr.com/86wnmm

下面的默认图标exapandablelistview的指标是显示在左侧。 我怎样才能显示在右边的列表视图中该图标指示? 有XML文件中的任何变化可以实现这一点?

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?

我的XML code是

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" />

`

推荐答案

setIndicatorBounds(INT左,右诠释)用来设置该指标界限的可扩展列表视图的组视图。

Expandable list view move group icon indicator to right

The setIndicatorBounds(int left, int right) is used to set the indicator bounds for the group view of an expandable list view.

explvList.setIndicatorBounds(width-GetDipsFromPixel(35), width-GetDipsFromPixel(5));
Here width means device width.

/Convert pixel to dip 
public int GetDipsFromPixel(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);
} 

供参考:的宽度为宽度在的setBounds 方式指定。在这里,我的片段是35.Other明智的图标被打乱。欲了解更多详情,您可以点击这里查看

FYI : The width is equal to width specified in the setBounds method. Here in my snippet it is 35.Other wise the icon is disturbed. For more details you may visit here

<一个href="https://developer.android.com/reference/android/widget/ExpandableListView.html#setIndicatorBounds(int" rel="nofollow">https://developer.android.com/reference/android/widget/ExpandableListView.html#setIndicatorBounds(int,   INT)

<一个href="https://developer.android.com/reference/android/widget/ExpandableListView.html#setIndicatorBoundsRelative(int" rel="nofollow">https://developer.android.com/reference/android/widget/ExpandableListView.html#setIndicatorBoundsRelative(int,   INT)

这篇关于如何使expandablelistview使用默认扩展右侧/折叠图标指示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆