In Android, I’m trying to accomplish this:

Basically, the ability to add the button side by side with an EditText, where they both take up 90% of the width of a top row. (I’m not concerned with having a logo like the twitter icon).
I’ve tried LinearLayout with layout_weight, but they didn’t appear properly at all:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum = "1.0"
android:orientation="vertical"
android:background = "#faadadad" >
<EditText
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_weight = "0.8"
android:layout_marginLeft = "2dip"
android:layout_marginTop = "1dip"
android:layout_marginBottom = "1dip"
android:hint="Search Terms" />
<Button android:text = "?"
android:layout_width = "0dip"
android:layout_height="2dip" android:layout_weight = "0.2"/>
</LinearLayout>
and anything I tried in RelativeLayout just didn’t look right (I tried setting the margin between the 2 element to 0dips, no luck. Also I couldn’t get the 90% of the width requirement either.)
What am I doing wrong? Thanks in advance.
Try using following:
So basically, when you using, horizontal LinearLayout, then layout_weight works horizontally i.e. width is divided according to layout_weight parameter (layout_width=”0dp”). If you are using vertical LinearLayout, then layout_weight works vertically i.e. height is divided vertically according to layout_weight parameter (layout_height=”0dp”).
Hope it will be helpful to you.