Android 自定义listview适配器xml截断字

Android 自定义listview适配器xml截断字,android,android-xml,android-adapter,Android,Android Xml,Android Adapter,我用自己的xml创建了一个customlistview适配器,左边应该是啤酒风格,右边应该是平均等级。我的问题是一些啤酒风格有很多字符长,并且被截断: 当前列表项的“我的xml”为: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pare

我用自己的xml创建了一个customlistview适配器,左边应该是啤酒风格,右边应该是平均等级。我的问题是一些啤酒风格有很多字符长,并且被截断:

当前列表项的“我的xml”为:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/breweryName"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:text="Large Text"
        android:layout_weight="4"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/breweryRate"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:layout_weight="1"
        android:textAppearance="?android:attr/textAppearanceLarge" />


</LinearLayout>

我认为这可能是您想要的,您只需要在啤酒名称上包装内容,而不是填充父项,以防止文本视图被截断

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/breweryName"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:layout_weight="4"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/breweryRate"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:layout_weight="1"
        android:textAppearance="?android:attr/textAppearanceLarge" />


</LinearLayout>

我相信您可能想做的是使用字幕。我将修改您的xml,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal" >

  <TextView
    android:id="@+id/breweryName"
    android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:text="Large Text"
    android:layout_weight="4"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:singleLine="true"
    android:textAppearance="?android:attr/textAppearanceLarge" />

  <TextView
    android:id="@+id/breweryRate"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:layout_weight="1"
    android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>