我正在尝试弄清楚如何在 EditText 小部件中嵌入除 Drawable 之外的东西。具体来说,我想到的示例来自 Google Buzz 小部件:
screenshot (没有内联图片,抱歉,我是新手)
在不经意的观察者看来,有一个完整的布局对象固定在 EditText 的底部,其中包含一个 ImageView、一个 TextView 和一个 Button。
有人知道如何解决这个问题吗?或者我们认为这是 EditText 的自定义子类?
最佳答案
EditText + Button + ... 这是一个 FrameLayout,EditText 带有 fill_parent,Buttons 带有 layout_gravitiy:"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>
关于android - 如何在 EditText 中嵌入 View (带有按钮等)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3018050/