Reputation: 385
As you can see in the picture the is remaning space to the right of the two buttons, i would like the search bar in the middle to extend as long as it cans, so there is no free space ,should i make those two buttons go to the right and in that way giving more space to the search bar to expand , if so how can i do that to?
LAYOUT
<LinearLayout android:id="@+id/findControls" android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="wrap_content" android:paddingTop="5dip"
android:paddingLeft="4dip" android:paddingRight="4dip"
android:paddingBottom="1dip" android:background="@drawable/topbar">
<ImageButton android:src="@drawable/ic_btn_find_prev"
android:id="@+id/find_previous" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton android:src="@drawable/ic_btn_find_next"
android:id="@+id/find_next" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true" />
<LinearLayout android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical" android:layout_marginRight="6dip">
<EditText android:id="@+id/find_value" android:layout_width="133dp"
android:layout_height="wrap_content" android:scrollHorizontally="true"
android:singleLine="true" android:ellipsize="end"
android:inputType="text" android:hint="@string/SearchDialog.Hint" />
</LinearLayout>
Upvotes: 0
Views: 117
Reputation: 3909
You could use a RelativeLayout instead:
<RelativeLayout android:id="@+id/findControls"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingBottom="1dip"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:paddingTop="5dip">
<ImageButton
android:id="@+id/find_previous"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add"/>
<ImageButton
android:id="@+id/find_next"
android:layout_toRightOf="@id/find_previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/ic_add"/>
<EditText
android:id="@+id/find_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:hint=""
android:layout_toRightOf="@id/find_next"
android:layout_toLeftOf="@id/find_next2"
android:inputType="text"
android:scrollHorizontally="true"
android:singleLine="true"/>
<ImageButton
android:id="@+id/find_previous2"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add"/>
<ImageButton
android:id="@+id/find_next2"
android:layout_toLeftOf="@id/find_previous2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/ic_add"/>
Align your Buttons to Parents Left/Right. Set your EditText in between with toLeftOf and toRightOf.
Upvotes: 0
Reputation: 932
try to use match_parent
as layout_width
. And definitly not fixed 133dp.
so for your LinearLayout
change from wrap_content
to match_parent
and add match_parent
to the EditText
<LinearLayout android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginRight="6dip"
android:layout_width="match_parent">
<EditText android:id="@+id/find_value" android:layout_width="match_parent"
android:layout_height="wrap_content" android:scrollHorizontally="true"
android:singleLine="true" android:ellipsize="end"
android:inputType="text" android:hint="@string/SearchDialog.Hint" />
</LinearLayout>
Upvotes: 0
Reputation: 1648
Try this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:background="@color/cardview_light_background">
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="2dp"
android:background="@color/cardview_dark_background"/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="2dp"
android:background="@color/cardview_dark_background"/>
<EditText
android:layout_weight="1"
android:layout_width="0dp"
android:layout_margin="2dp"
android:layout_height="match_parent"/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="2dp"
android:background="@color/cardview_dark_background"/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="2dp"
android:background="@color/cardview_dark_background"/>
</LinearLayout>
Upvotes: 1