Combining EditText and Button?

冷暖自知 提交于 2019-12-06 07:15:47

问题


In some apps I see an EditText widget combined with a Button on the right side (e.g. the search field in the twitter app). How can I create a widget like that?

Regards, Marco


回答1:


I finally found a solution. Here's how the google guys did it: search_bar.xml Thanks for your help!




回答2:


Check out the TableLayout and the RelativeLayout in the Android developer center.

There are a few more official tutorials on layouts here.

If you use the TableLayout, you can put an EditText in the left column of a two column layout, and then put the button on the right. Or, probably a better way, would be to use a RelativeLayout, which gives you a little more flexibility.




回答3:


Take a look at Applying Styles and Themes and the Draw 9-patch tool. 9-patches are used as the background for widgets like EditText and Button. You can combine a custom widget background with padding and margins to get the effect you want.



来源:https://stackoverflow.com/questions/2950885/combining-edittext-and-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!