Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed a View (with Buttons, etc.) inside an EditText?

I'm trying to figure out how to embed things, other than Drawables, inside an EditText widget. Specifically the example I'm thinking of is from the Google Buzz widget:

screenshot (no inline image, sorry, I'm a newb)

It appears to the casual observer that there's an entire layout object pinned to the bottom of the EditText, containing an ImageView, a TextView, and a Button.

Anyone have any idea how to pull this off? Or do we think this is a custom subclass of EditText?

like image 761
Hugh Avatar asked Jun 10 '10 20:06

Hugh


1 Answers

The EditText + Button + ... it's a FrameLayout with the EditText with fill_parent and the Buttons with layout_gravitiy:"bottom". Something like this:

<?xml version="1.0" encoding="utf-8"?> <!-- Main Layout (may be relative or whatever --> <RelativeLayout    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <!-- Layout for edittext and button -->
    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:lines="5"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_margin="5dip"
            android:text="Overflow"/>

    </FrameLayout>

    <!-- More layouts ..... -->   </RelativeLayout>
like image 68
YaW Avatar answered Sep 30 '22 01:09

YaW