群体指标变形了吗?

时间:2015-09-08 14:41:46

标签: java android listview expandablelistview

我使用带有组指示符的ExpandableListView。组指示器图像应放置在组视图的右侧,并垂直居中,不得有任何失真。

以下是它的样子:

enter image description here

未失真的图像如下所示:

enter image description here enter image description here

这是我的布局:

<ExpandableListView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:groupIndicator="@drawable/list_group_indictor"
    android:divider="@color/whiteColor"
    android:dividerHeight="1dp" />

这是样式list_group_indictor

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:drawable="@drawable/carat_right" />

    <item
        android:drawable="@drawable/carat_down"
        android:state_expanded="true" />

</selector>

如何将组指示器放在右侧,放置在垂直中心而不会失真?

编辑:我尝试使用内容填充使用this工具生成9补丁图片。结果如下:

enter image description here

1 个答案:

答案 0 :(得分:0)

你应该使用 9个补丁,而不是普通的png 只需将顶部和左侧标记放在空白区域上即可拉伸这些部分(这会导致在缩放时添加一些填充)。

9个补丁的精彩教程将让您了解为什么需要使用它们,比我的话更好:http://radleymarx.com/blog/simple-guide-to-9-patch/

<强> [编辑]

这些是补丁:

enter image description here

enter image description here

这就是他们在draw9patch工具中看到的样子 - 您可以清楚地看到9个补丁标记的实际效果:

enter image description here

enter image description here

您可以看到箭头没有伸展,只有周边的透明部分 这是期望的效果。

请注意,扩展程序必须是 .9.png ,而不是 .png

相关问题