2013-03-07 1 views
0

나는 내가 화면에 거품을 표시하는 9 패치 거품을이상한 행동은

기능을 사용하고 그에 대한 채팅 응용 프로그램을 개발하고

static void showMessage(String message, boolean leftSide) 
    { 
     Log.d("abc","show"); 
     final TextView textView = new TextView(activity); 
     textView.setTextColor(Color.BLACK); 
     textView.setText(message); 

     int bgRes = R.drawable.left_message_bg; 

     LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
       LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); 



     if (!leftSide) 
     { 
      bgRes = R.drawable.right_message_bg; 
      params.gravity = Gravity.RIGHT; 


     } 

     textView.setLayoutParams(params); 

     textView.setBackgroundResource(bgRes); 

     messagesContainer.addView(textView); 

       // Scroll to bottom 
     if (scrollContainer.getChildAt(0) != null) 
        { 

        scrollContainer.scrollTo(scrollContainer.getScrollX(), scrollContainer.getChildAt(0).getHeight()); 

       } 

       scrollContainer.fullScroll(View.FOCUS_DOWN); 

      } 

XML 레이아웃

<?xml version="1.0" encoding="utf-8"?> 


<EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/messageEdit" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentBottom="true" 
     android:autoText="true" 
     android:hint="message text" 
     android:layout_alignParentRight="false" 
     android:layout_toLeftOf="@+id/sendButton" 
     android:layout_marginRight="10dp"/> 
<Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Send" 
     android:id="@+id/sendButton" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentBottom="true"/> 

<ScrollView 
     android:id="@+id/scrollContainer" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="false" 
     android:layout_alignParentTop="false" 
     android:layout_marginBottom="20dp" android:layout_above="@+id/messageEdit" 
     android:layout_below="@+id/meLabel" android:layout_marginTop="10dp"> 
    <LinearLayout 
      android:id="@+id/messagesContainer" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
    </LinearLayout> 
</ScrollView> 
<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/headerforchat" 
     android:text="Me" 
     android:id="@+id/meLabel" android:layout_gravity="left|center_vertical" android:singleLine="false" 
     android:textSize="20dp"/> 
<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/headerforchat" 
     android:text="Friend" 
     android:id="@+id/friendLabel" android:layout_alignParentRight="true" android:textSize="20dp"/> 

</RelativeLayout> 

하지만 안드로이드 2.3에서 테스트했을 때 이상한 행동을합니다. 삼성 Glaxy S3에서 멋지게 보입니다.

enter image description here

1 일 isGalaxy (S3)의 스크린 샷 Glaxy s3 result

. 2 일 개 안드로이드 2.3 screenshot.Blue 거품이 어떤 도움이

을 이해할 수있을 것이다 안드로이드 2.3

left_message_bg-->The orange bubble which will display after sending message 

right_message_bg-->The blue bubble which will display after receiving message 

9 패치 이미지

enter image description here enter image description here

에 이상한 표시되어

답변

1

내 생각 엔 당신이 하나의 드로어 블 폴더 (drawable-xhdpi)에만 9 패치를 넣었습니다. 이 아니며 xhdpi가 아닌 장치에 배치하면 정의 된 바깥 쪽 검은 색 픽셀을 포함하여 크기가 축소되고 더 이상 9 패치로 해석 될 수 없으므로 실패합니다. 축소 된 mdpi 및 hdpi 버전을 만들거나 drawable-nodpi에 배치하십시오.

+0

다른 밀도로 모든 폴더에 넣었습니다. –

+0

문제가있는 9 패치를 게시 할 수 있습니까? – kcoppock

+0

이미지 추가 ... –