Android 如何在EditText中嵌入视图(带有按钮等)?

Android 如何在EditText中嵌入视图(带有按钮等)?,android,android-widget,Android,Android Widget,我试图弄清楚如何在EditText小部件中嵌入除Drawables之外的东西。具体来说,我想到的例子来自Google Buzz小部件: (没有内联图像,对不起,我是新手) 在不经意的观察者看来,EditText底部固定着一个完整的布局对象,其中包含一个ImageView、一个TextView和一个按钮 有人知道怎么做吗?或者我们认为这是EditText的一个自定义子类吗?我认为他们在这里所做的是为他们的布局创建一个看起来像EditText的背景。然后他们添加了一个背景关闭的EditText和c

我试图弄清楚如何在EditText小部件中嵌入除Drawables之外的东西。具体来说,我想到的例子来自Google Buzz小部件:

(没有内联图像,对不起,我是新手)

在不经意的观察者看来,EditText底部固定着一个完整的布局对象,其中包含一个ImageView、一个TextView和一个按钮


有人知道怎么做吗?或者我们认为这是EditText的一个自定义子类吗?

我认为他们在这里所做的是为他们的布局创建一个看起来像EditText的背景。然后他们添加了一个背景关闭的EditText和come按钮。

EditText+按钮+。。。这是一个框架布局,编辑文本带有填充父项,按钮带有布局“底部”。大概是这样的:

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

您可以在EditText中使用嵌入按钮的框架布局,这里我给出了EditText中嵌入TextView的示例代码,只需将TextView更改为按钮即可

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

我想这是可能的,不过如果你用轨迹球玩聚焦链,情况似乎不是这样。