【发布时间】:2014-10-15 16:23:11
【问题描述】:
我正在尝试使用 TableLayout 中可点击的搜索按钮(没有 rightDrawable 内容)创建一个搜索文本字段。我已经在 RelativeLayout 中看到了这一点,但我不知道如何在 TableLayout 中做到这一点。这是我的activity_main.xml:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/TableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="android.tabcards.app.MainActivity" >
<TableRow
android:id="@+id/searchTableRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter search key" />
<ImageButton
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="30dp"
android:src="@drawable/search"
android:text="Button" />
</RelativeLayout>
</TableRow>
</TableLayout>
我正在尝试实现这样的目标:
______________________
|Enter Text Here |->|
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
编辑:这是现在的样子:
【问题讨论】:
-
你的 xml 有什么问题?
-
我希望按钮位于 EditText 内,如帖子末尾所示
标签: android button android-edittext tablelayout