android中带气球的listview
我正在尝试创建带有引出序号的listview。它就像一个线程化的聊天列表。 我正在为气球使用thread.9.png(9面片图像)图像。但是你可以在上面的屏幕截图中看到,即使内容更小,气球也会占据屏幕宽度 我想根据内容调整引出序号的宽度 下面是列表视图行的代码android中带气球的listview,android,listview,Android,Listview,我正在尝试创建带有引出序号的listview。它就像一个线程化的聊天列表。 我正在为气球使用thread.9.png(9面片图像)图像。但是你可以在上面的屏幕截图中看到,即使内容更小,气球也会占据屏幕宽度 我想根据内容调整引出序号的宽度 下面是列表视图行的代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/andr
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dp"
android:background="@drawable/thread">
<TextView
android:text="TextView"
android:id="@+id/messageFrom"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_weight="1.0"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginTop="20dip"></TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:id="@+id/messageTitle"
android:text="TextView"
android:layout_gravity="right"
android:layout_marginBottom="20dip"></TextView>
<TextView
android:layout_weight="1.0"
android:gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"
android:id="@+id/messageDay"
android:text="TextView" android:layout_marginLeft="20dip"></TextView>
</LinearLayout>
如果有线程列表视图的示例,它也会非常有用。一个9patch图像不会收缩(只会拉伸),因此如果线程.9.png的宽度大于内容大小,它将使用图像宽度。一个9patch图像不会收缩(只会拉伸),因此如果线程.9.png的宽度大于内容大小,它将使用图像宽度。您必须以所需的最小宽度设计气球背景图像您必须以所需的最小宽度设计气球背景图像尝试使用子线性布局,因为列表行填充主布局,即使您将宽度设置为换行内容
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_bg1" android:padding="10dp">
<TextView android:text="text view one" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textColor="#ffff0000" android:textSize="20dp" android:id="@+id/text1"/>
<TextView android:text="text view two" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textColor="#ffff0000" android:textSize="20dp" android:id="@+id/text2"/>
</LinearLayout>
</LinearLayout>
尝试使用子线性布局,因为即使您将宽度设置为包裹内容,列表行也会填充主布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_bg1" android:padding="10dp">
<TextView android:text="text view one" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textColor="#ffff0000" android:textSize="20dp" android:id="@+id/text1"/>
<TextView android:text="text view two" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textColor="#ffff0000" android:textSize="20dp" android:id="@+id/text2"/>
</LinearLayout>
</LinearLayout>
有没有最小宽度的建议?有没有最小宽度的建议??