Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining EditText and Button?

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

like image 842
Marco Avatar asked Feb 26 '26 15:02

Marco


2 Answers

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

like image 156
Marco Avatar answered Feb 28 '26 05:02

Marco


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.

like image 34
Ryan Hayes Avatar answered Feb 28 '26 05:02

Ryan Hayes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!