简体   繁体   English

Expandablelistview自定义groupview高

[英]Expandablelistview custom groupview to high

I have Expandablelistview with custom UI. 我有带有自定义UI的Expandablelistview。 I defined adapter extended from BaseExpandableListAdapter. 我定义了从BaseExpandableListAdapter扩展的适配器。 I want my groupviews to be exactly 25dp height, but they are higher 我希望群组视图的高度恰好是25dp,但它们应该更高

my xml is ` 我的xml是

<TextView
    android:id="@+id/product_name"
    android:layout_width="0dp"
    android:layout_height="25dp"
    android:layout_weight="2"
    android:gravity="center_vertical"
    android:paddingLeft="15dp"
    android:text="@string/products"
    android:textSize="12sp"
    android:textStyle="bold" />

<TextView
    android:layout_width="0dp"
    android:layout_height="25dp"
    android:layout_marginLeft="25dp"
    android:layout_weight="1"
    android:gravity="center"
    android:text="@string/weight_g"
    android:textSize="12sp"
    android:textStyle="bold" />

<TextView
    android:layout_width="0dp"
    android:layout_height="25dp"
    android:layout_weight="1.6"
    android:gravity="center"
    android:text="@string/measure"
    android:textSize="12sp"
    android:textStyle="bold" />

` `

and my code 和我的代码

@Override
    public View getGroupView(final int groupPosition,
            final boolean isExpanded, final View convertView,
            final ViewGroup parent) {
        final View view = View.inflate(context,
                R.layout.header_measurements, null);

        final TextView title = (TextView) view
                .findViewById(R.id.product_name);
        title.setText(data.get(groupPosition).categoryName);

        return view;
    }

you left out the most important part. 您忽略了最重要的部分。 what does the container (LinearLayout or RelativeLayout, etc) of your textviews in the xml say? xml中的textview的容器(LinearLayout或RelativeLayout等)怎么说? the layout height should either say android:layout_height="25dp" or android:layout_height="wrap_content" 布局高度应为android:layout_height="25dp"android:layout_height="wrap_content"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM