【发布时间】:2011-02-26 09:52:01
【问题描述】:
在某些应用程序中,我看到 EditText 小部件与右侧的按钮组合在一起(例如 search field in the twitter app)。 我怎样才能创建这样的小部件?
问候, 马可
【问题讨论】:
标签: android user-interface button android-edittext
在某些应用程序中,我看到 EditText 小部件与右侧的按钮组合在一起(例如 search field in the twitter app)。 我怎样才能创建这样的小部件?
问候, 马可
【问题讨论】:
标签: android user-interface button android-edittext
我终于找到了解决办法。 以下是谷歌人的做法:search_bar.xml 感谢您的帮助!
【讨论】:
Check out the TableLayout and the RelativeLayout in the Android developer center.
还有一些关于布局的官方教程here。
如果你使用TableLayout,你可以在一个两栏布局的左边栏放一个EditText,然后把按钮放在右边。或者,可能更好的方法是使用RelativeLayout,它可以为您提供更多的灵活性。
【讨论】:
看看Applying Styles and Themes 和Draw 9-patch 工具。 9-patches 用作 EditText 和 Button 等小部件的背景。您可以将自定义小部件背景与填充和边距相结合,以获得您想要的效果。
【讨论】: