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

I'm trying to figure out how to embed things besides Drawables inside an EditText widget. In particular, the example I'm thinking of is related to Google Buzz widgets:

screenshot (no embedded image, sorry I'm new)

It seems to the casual observer that the entire layout object is attached to the bottom of the EditText containing the ImageView, TextView, and button.

Does anyone know how to do this? Or do we think this is a custom subclass of EditText?

+7
android android widget
source share
3 answers

The EditText button + + ... is FrameLayout with EditText with fill_parent and buttons with layout_gravitiy: "bottom". Something like that:

<?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> 
+15
source share

you can use the frame layout for the insert button in EditText, here I give a sample code to insert the TextView in EditText, just change the TextView as Button

 <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="40px" android:layout_y="35px" > <EditText android:id="@+id/twt_post_content" android:layout_gravity="center_vertical" android:layout_width="320dp" android:layout_height="140dp" android:paddingTop="5dp" android:imeOptions="actionDone" android:gravity="left" android:focusableInTouchMode="true" android:maxLength="140" android:ellipsize="end" /> <TextView android:text="123" android:paddingLeft="270dp" android:paddingTop="100dp" android:layout_alignParentRight="true" android:id="@+id/twt_content_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/red" android:layout_gravity="center" android:background="@color/transparent"/> </FrameLayout> 
+1
source share

I think what they did here creates a background for their layout, which looks like an EditText. Then they added EditText with the background turned off and buttons come.

0
source share

All Articles