1

Whatsapp 또는 Telegram과 같은 작업을 수행하는 방법이 궁금합니다. 그들이 보내는 텍스트의 크기와 상관없이 항상 멋지게 보입니다. my chat bubbleAndroid : 동적으로 변화하는 이미지를 만드는 방법이 여전히 좋아 보이십니까?

지금 난 내 응용 프로그램에서 이것을 사용합니다 : (이 chat_bubble.png로 저장)

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="0dp" 
    android:layout_marginRight="0dp" 
    android:id="@+id/list_item" 
    android:gravity="right"> 

    <LinearLayout 
     android:id="@+id/row_message" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="5dip" 
     android:layout_marginLeft="5dip" 
     android:layout_marginRight="5dip" 
     android:layout_marginTop="5dip" 
     android:background="@drawable/chat_bubble" 
     android:orientation="horizontal" 
     android:singleLine="false" > 

     <TextView 
      android:id="@+id/list_item_text_view" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginTop="5dp" 
      android:paddingLeft="5dp" 
      android:text="ProgramTitle" 
      android:textColor="@android:color/white" 
      android:textSize="20sp" /> 

     <ImageView 
      android:id="@+id/messageIcon" 
      android:layout_width="20dp" 
      android:layout_height="20dp" 
      android:layout_marginTop="15dp" 
      android:layout_marginRight="10dp" 
      android:padding="2dp" 
      android:src="@drawable/wait" /> 
    </LinearLayout> 

</LinearLayout> 

이 레이아웃입니다

나는 내가이 사진을 만든이 나 자신을하려고 노력 내 ListView의 모든 ListItem에 대해.

chat bubble with less text

을하지만 더 긴 텍스트를 사용하는 경우 더 이상 잘 보이지 않는, 그래서 사진이 뻗어됩니다 : 은 다음과 같습니다 이 chat bubble with more text

이제 내 질문에, 어떻게이 있습니다 이 문제가 없을 수도 있습니다. 이 문제를 해결할 수있는 좋은 아이디어가 있습니까? 굉장 할 것입니다.

답변

2

이미지에서 9 패치를 만들어야합니다.

Android Dev에 대한 튜토리얼을 참조하십시오. 사이트 : http://developer.android.com/tools/help/draw9patch.html

9 패치 이미지에서 이미지의 어느 부분이 "신축성"이고 어떤 부분이 아닌지 선언합니다. 기본적으로 .png 이미지입니다. 이미지의 1 픽셀 부분이 이 부분을으로 늘리면 안드로이드에 알려줍니다. 이미지는 something.9.png이라는 drawable 디렉토리에 저장해야하며 @drawable/something으로 참조 할 수 있습니다.

Android SDK에는 일반적인 이미지로 9 패치 이미지를 만드는 작은 프로그램이 포함되어 있습니다.

+0

감사합니다. – progNewbie

관련 문제