Expandablelistview自定义groupview为高

时间:2012-11-25 22:43:00

标签: android expandablelistview

我有自定义UI的Expandablelistview。我定义了从BaseExpandableListAdapter扩展的适配器。我希望我的群组视图正好是25dp高度,但它们更高

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

`

和我的代码

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

1 个答案:

答案 0 :(得分:0)

你遗漏了最重要的部分。 xml中textviews的容器(LinearLayout或RelativeLayout等)说什么?布局高度应该是android:layout_height="25dp"android:layout_height="wrap_content"

相关问题