나는 마녀에서 안드로이드 프로그래밍을 배우기위한 채팅 응용 프로그램을 작성 중이므로 목록에있는 사용자에게 대화를 보여줍니다. 대화 목록의 모든 항목은 객체 집합과 버블 배경이있는 EditText
입니다. 하지만 대화를 표시 할 때 EditText
은 내용을 감싸지 않고 EditText
의 크기는 대화의 모든 행에서 동일합니다.Drawable 배경을 가진 Edittext는 내용을 포장하지 않습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/llmain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables" >
<TextView
android:id="@+id/txtTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/chatdate"
android:gravity="center"
android:textAlignment="gravity"
android:textSize="8sp" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/llTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/chatme"
android:gravity="top|right"
android:paddingTop="7dp"
android:textAlignment="gravity"
android:visibility="visible" >
<ImageView
android:id="@+id/imgStatusTo"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:scaleType="fitXY"
android:src="@drawable/wait_ic" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.82"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgChatConversationToFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/ic_info" />
<TextView
android:id="@+id/txtChatConversationTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="60dp"
android:autoLink="web"
android:background="@color/chatme"
android:drawableBottom="@color/jigari"
android:drawableLeft="@color/jigari"
android:drawableRight="@color/jigari"
android:drawableTop="@color/jigari"
android:gravity="right|top"
android:inputType="none"
android:linksClickable="true"
android:paddingLeft="20dp"
android:paddingRight="40dp"
android:paddingTop="5dp"
android:scrollHorizontally="false"
android:scrollbars="none"
android:selectAllOnFocus="true"
android:singleLine="false"
android:textDirection="rtl" />
</LinearLayout>
<ImageView
android:id="@+id/imgChatConversationTo"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="bottom"
android:layout_marginBottom="5dp"
android:background="@color/gray"
android:contentDescription="@string/user_image"
android:scaleType="fitXY"
android:src="@drawable/ic_user_image" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/llFrom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/chatyou"
android:paddingTop="7dp"
android:visibility="visible" >
<ImageView
android:id="@+id/imgChatConversationFrom"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@color/gray"
android:contentDescription="@string/user_image"
android:scaleType="fitXY"
android:src="@drawable/ic_user_image" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.82"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgChatConversationFromFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/ic_info" />
<TextView
android:id="@+id/txtChatConversationFrom1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginRight="60dp"
android:autoLink="web"
android:background="@color/chatyou"
android:gravity="top|right"
android:inputType="none"
android:linksClickable="true"
android:paddingLeft="45dp"
android:paddingRight="20dp"
android:paddingTop="3dp"
android:scrollHorizontally="false"
android:scrollbars="none"
android:selectAllOnFocus="true"
android:singleLine="false"
android:textAlignment="gravity" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
내 문제가 txtConversationFrom
및 txtConversationTo
에 :
여기 내 대화 항목의 코드입니다. 코드 i에서 은 필요하지 않은 항목을 숨 깁니다.
어떻게하면 EditText
을 텍스트를 줄 바꿈하고 텍스트 크기에 맞게 크기를 조정할 수 있습니까?
예는 텍스트 뷰입니다 :
그리고 아마가에 txtChatConversationTo 텍스트 뷰가 포함 된 LinearView의 폭을 설정합니다. 텍스트는 여러 줄로 나뉘어져 있지만 파손되지는 않지만 textView의 높이는 모든 텍스트에서 동일합니다. 내 말은 크기가 일정하고 어떤 텍스트에 대해서도 변경 사항이 표시되지 않는다는 의미입니다. –
음, 만약 당신이 Theme.Holo 스타일을 사용하고 있다면 당신은 [this] (http://stackoverflow.com/questions/11583261/textview-wont-break-text/13032036#13032036) – iQzero
을 읽을 수 있습니다. 나를 위해 일하지 마! 대화보기에서 viber와 line과 같은 거품을 갖고 싶습니다. –