Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:04:05+00:00 2026-06-09T20:04:05+00:00

In iPhone there is a method on UIImage called stretchableimagewithleftcapwidth which can be used

  • 0

In iPhone there is a method on UIImage called stretchableimagewithleftcapwidth which can be used to create a chat bubble to stretch for any size (keeping the corners natural size).

We don’t seem to have this in Android so I’ve set out to make a layout that I can then use as a background image with a FrameLayout. The trouble I’m having at the moment is the top row which consists of 3 columns: the left top corner, the stretchable top, and the right top corner. How do I get the left and right top corners to remain fixed size (11dip) and tell the middle to fill any remaining space in the parent? This is what I have so far.

<?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>

Here is the layout tree in eclipse if this helps.
visualised layout

Here is what it looks like rendered in the layout editor in eclipse. Note the top and bottom rows not stretching appropriately.

enter image description here

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:04:07+00:00Added an answer on June 9, 2026 at 8:04 pm

    i also needed a chat bubble kind of view in my app so I used a 9 patch drawable as the background image and it is working fine.

    check this question:

    Why do 9-patch graphics size correctly in the emulator but not on a phone?

    And also this link:

    http://warting.se/2012/06/04/chat-bubbles-in-android/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since KVC is used to set outlets on the iPhone, there are 2 methods
Are there any game engines for iPhone?
Is there any way to access the iPhone/iPod touch settings programatically ? Thanks. Biranchi
do there any dev who wrote iPhone wifi/bluetooth multiplay before? Recently, I'm trying to
is there any easy way in the iPhone SDK to include search bars like
I was wondering if there is a method similar to UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget,
Here is a fast one: is there any method for releasing any cached data
Am developing an app in iphone in which reports can be sent through email.
Is there any way other than thumbnail method to take a screenshot of an
Is there a special method to get iPhones orientation? I don't need it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.