2012-08-13 2 views
0

iPhone에는 UIImage에 stretchableimagewithleftcapwidth라는 메서드가 있습니다.이 메서드는 모든 크기 (자연 모서리 크기 유지)를 위해 스트레칭하기 위해 채팅 거품을 만드는 데 사용할 수 있습니다.스카 이프 스타일의 텍스트 입력 버블에 대한 레이아웃 만들기

우리는 안드로이드에서 이걸 가지고있는 것 같지 않아서 FrameLayout으로 배경 이미지로 사용할 수있는 레이아웃을 만들었습니다. 제가 지금 가지고있는 문제는 3 개의 기둥으로 구성된 맨 위 행입니다 : 왼쪽 상단 구석, 늘릴 수있는 꼭대기 및 오른쪽 꼭대기 구석. 왼쪽 상단 모서리와 오른쪽 상단 모서리를 고정 된 크기 (11dpi)로 유지하고 중간에 부모의 나머지 공간을 채우라고 말하면 어떻게됩니까? 이것은 내가 지금까지 가지고있는 것이다. 이 도움이된다면 여기

<?xml version="1.0" encoding="UTF-8"?> 
    <merge xmlns:android="http://schemas.android.com/apk/res/android"> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/layout_bubble_container" 
    android:orientation="vertical">  
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="11dip" 
     android:id="@+id/layout_bubble_toprow" 
     android:orientation="horizontal">  
     <LinearLayout 
      android:id="@+id/layout_top_leftCorner" 
      android:layout_width="11dip" 
      android:layout_height="fill_parent" 
      android:gravity="left|top"> 
      <ImageView 
       android:id="@+id/bubble_top_leftcorner" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:src="@drawable/bubble_lefttop" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/layout_top" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:gravity="top|center" > 

      <ImageView 
       android:id="@+id/bubble_top" 
       android:layout_width="match_parent" 
       android:layout_height="fill_parent" 
       android:scaleType="fitXY" 
       android:src="@drawable/bubble_top" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/layout_top_rightCorner" 
      android:layout_width="11dip" 
      android:layout_height="fill_parent" 
      android:gravity="right|top" > 

      <ImageView 
       android:id="@+id/bubble_top_rightcorner" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:src="@drawable/bubble_righttop" /> 
     </LinearLayout>  
    </LinearLayout> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="11dip" 
     android:id="@+id/layout_bubble_middlerow" 
     android:orientation="horizontal" 
     android:background="@color/WHITE">  
     <LinearLayout 
      android:id="@+id/layout_left" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:gravity="left" 
      android:layout_weight="1"> 
      <ImageView 
       android:id="@+id/bubble_left" 
       android:layout_width="11dip" 
       android:layout_height="fill_parent" 
       android:src="@drawable/bubble_left" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/layout_right" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:gravity="right" 
      android:layout_weight="1"> 

      <ImageView 
       android:id="@+id/bubble_right" 
       android:layout_width="11dip" 
       android:layout_height="fill_parent" 
       android:src="@drawable/bubble_right" /> 
     </LinearLayout>  
    </LinearLayout> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="11dip" 
     android:id="@+id/layout_bubble_bottomrow" 
     android:orientation="horizontal">  
     <LinearLayout 
      android:id="@+id/layout_bottom_leftCorner" 
      android:layout_width="11dip" 
      android:layout_height="fill_parent" 
      android:gravity="left|top"> 
      <ImageView 
       android:id="@+id/bubble_bottom_leftcorner" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:src="@drawable/bubble_leftbottom" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/layout_bottom" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:gravity="top|center" > 

      <ImageView 
       android:id="@+id/bubble_bottom" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:scaleType="fitXY" 
       android:src="@drawable/bubble_bottom" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/layout_bottom_rightCorner" 
      android:layout_width="11dip" 
      android:layout_height="fill_parent" 
      android:gravity="right|top" > 

      <ImageView 
       android:id="@+id/bubble_bottom_rightcorner" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:src="@drawable/bubble_rightbottom" /> 
     </LinearLayout>  
    </LinearLayout> 
</LinearLayout> 

이클립스에서 레이아웃 트리입니다. visualised layout

다음은 이클립스의 레이아웃 편집기에서 렌더링 한 모양입니다. 상단 및 하단 행이 적절하게 늘어나지 않도록주의하십시오. 사전에

enter image description here

감사합니다.

+1

안녕, 나 또한 내 응용 프로그램에서보기의 채팅 거품의 종류를 필요는 그래서 9 패치를 사용 배경 이미지로 드로어 블 가능하며 정상적으로 작동합니다. 이 질문을 확인하십시오 : http://stackoverflow.com/questions/5096537/why-do-9-patch-graphics-size-correctly-in-the-emulator-but-not-on-a-phone – mudit

+0

이것을 척하고 싶습니다. 대답으로 받아 들일 수 있을까요? –

답변

관련 문제