listview项目文本对齐方式

时间:2011-09-29 14:54:28

标签: android text listviewitem

我有一个列表布局,每个项目使用9patch .png - 我有一个小文本对齐问题,如附图中所示。

任何想法如何解决?

这是第一个条目布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:background="@drawable/list_up" >
    <TextView
        android:id="@+id/listUp_RecipeIngredientNameTextBoxId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="14dip" />

</LinearLayout>

这是第二个条目布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:background="@drawable/list_middle" >
    <TextView
        android:id="@+id/listMiddle_RecipeIngredientNameTextBoxId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="14dip" />

</LinearLayout>

enter image description here

1 个答案:

答案 0 :(得分:0)

假设list_middle和list_up是9patch drawables,差异应该在9patch图像中指定的“padding”中。您可以解决这个问题,使得9patch在边框中具有相同数量的像素(即9patch的“左”部分的宽度和9patch的“顶部”部分的高度)。