如何嵌入一个视图(用按钮等)内一个EditText? [英] How to embed a View (with Buttons, etc.) inside an EditText?
问题描述
我试图找出如何嵌入事情,等的比可绘制一个EditText小部件内。具体的例子我想的是从谷歌Buzz小工具:
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)
这似乎是漫不经心的观察者是有固定到的EditText底部的整个布局对象,包含ImageView的,一个TextView和一个Button。
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.
任何人有任何想法如何退出这个功能?或者,我们认为这是EditText上的自定义子类?
Anyone have any idea how to pull this off? Or do we think this is a custom subclass of EditText?
推荐答案
本的EditText +按键+ ...它与EditText上与FILL_PARENT和layout_gravitiy按键一的FrameLayout:底。事情是这样的:
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>
这篇关于如何嵌入一个视图(用按钮等)内一个EditText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!