如上图所示,EditText 超出了它的父级,如何防止这种情况发生?
在我的聊天活动中,我使用 ListView 来显示消息,每条消息都是一个列表项
这是xml文件:
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/form"
android:layout_below="@+id/header"
android:divider="@null"
android:dividerHeight="0dp"
android:padding="5dp" >
</ListView>
并列出项目:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/avatarLeft"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/border"
android:contentDescription="@string/empty_string"
android:src="@drawable/icon_default_avatar"
android:visibility="gone" /> this will be adjusted programmatically
<TextView
android:id="@+id/comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" this will be adjusted programmatically
android:layout_margin="5dp"
android:background="@drawable/none" this will be adjusted programmatically
android:ellipsize="none"
android:paddingLeft="10dp"
android:singleLine="false"
android:text=""
android:textColor="@android:color/primary_text_light" />
<ImageView
android:id="@+id/avatarRight"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/border"
android:contentDescription="@string/empty_string"
android:src="@drawable/icon_default_avatar"
android:visibility="gone" /> this will be adjusted programmatically
</LinearLayout>