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

Hug*_*ugh 8 android android-widget

我试图找出如何嵌入的事情,其他的不是可绘制一个EditText小部件内.具体来说,我想到的例子来自Google Buzz小部件:

截图 (没有内联图片,抱歉,我是新手)

这似乎不经意的观察是有固定的EditText上底部的整个布局对象,包含一个ImageView的,一个TextView和一个Button.

任何人都知道如何解决这个问题?或者我们认为这是EditText的自定义子类?

YaW*_*YaW 15

EditText + Button + ...它是一个带有fill_parent的EditText和带有layout_gravitiy的按钮的FrameLayout:"bottom".像这样的东西:

<?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>
Run Code Online (Sandbox Code Playgroud)

  • 好的答案 - 这应该标记正确. (2认同)

Cas*_*eyB 0

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