Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange behavior of Android 9 patch image
    text
    copied!<p>I am developing a chat application for that I am using 9 patch bubble</p> <p>Function for displaying the bubble on screen</p> <pre><code> 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); } </code></pre> <p>XML Layout</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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"/&gt; &lt;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"/&gt; &lt;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"&gt; &lt;LinearLayout android:id="@+id/messagesContainer" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;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"/&gt; &lt;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"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>But is giving strange behavior when tested on android 2.3.Its looking nice in Samsung Glaxy S3 </p> <p><img src="https://i.stack.imgur.com/uCb54.png" alt="Glaxy s3 result"></p> <p><img src="https://i.stack.imgur.com/uJgPW.jpg" alt="enter image description here"></p> <p>1st one isGalaxy S3 screenshot. 2nd one Android 2.3 screenshot.Blue bubble is showing weird in android 2.3</p> <pre><code>left_message_bg--&gt;The orange bubble which will display after sending message right_message_bg--&gt;The blue bubble which will display after receiving message </code></pre> <p>9 patch images</p> <p><img src="https://i.stack.imgur.com/wPgFY.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/gKnBX.png" alt="enter image description here"></p> <p>Any help will be appreciated</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload