0

XML code here

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android">



    <EditText android:id="@+id/find_text"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_weight="1.0"
              android:layout_marginLeft="5dip"
              android:layout_marginRight="5dip"
              android:contentDescription="@string/find_text"
              android:background="@drawable/url_bar_entry"
              android:singleLine="true"
              android:textColor="#000000"
              android:textCursorDrawable="@null"
              android:inputType="text"
              android:paddingLeft="15dip"
              android:paddingRight="15dip"
              android:textColorHighlight="@color/url_bar_text_highlight"
              android:imeOptions="actionSearch"
              android:selectAllOnFocus="true"
              android:gravity="center_vertical|left"/>

    <ImageButton android:id="@+id/find_prev"
                 style="@style/FindBar.ImageButton"
                 android:contentDescription="@string/find_prev"
                 android:src="@drawable/find_prev"/>

    <ImageButton android:id="@+id/find_next"
                 style="@style/FindBar.ImageButton"
                 android:contentDescription="@string/find_next"
                 android:src="@drawable/find_next"/>

    <ImageButton android:id="@+id/find_close"
                 style="@style/FindBar.ImageButton"
                 android:contentDescription="@string/find_close"
                 android:src="@drawable/find_close"/>

</RelativeLayout>

I am inflating this menu by using this:

 LayoutInflater inflater = LayoutInflater.from(mContext);
 View content = inflater.inflate(R.layout.find_in_page_content, null);
 EditText tv = (EditText) content.findViewById(R.id.find_text);
 ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
 tv.setLayoutParams(params);
 //CODE TO ADD TO only EditText view to menu object I have

The outcome of this is seen here: http://imgur.com/sQZ7Lbh

My question is:, how can I make the url bar take up as much space as availble in the actiobar rather than be restricted to a tiny square. I also want the cursor to show up when pressed but it doesn't. However, I think that this is fixed when I make the url bar longer.

KPERI
  • 233
  • 3
  • 9

1 Answers1

0

Set this gravity attribute in XML in your RelativeLayout

android:layout_gravity="fill_horizontal"

Taken from https://stackoverflow.com/a/12884297/2158970

Community
  • 1
  • 1
Yuraj
  • 3,185
  • 1
  • 23
  • 42