tags:

views:

345

answers:

4

I want to make the edittext width the same size as button. My EditText is currently very small. I use relative layout.

   <TextView   
    android:id="@+id/aha4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="17dip"
    android:text="Vzdevek:"
    android:layout_below="@id/aha3" />  
     <EditText android:id="@+id/nick"       
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"     
        android:layout_below="@id/nivo"
        android:layout_toRightOf="@id/aha4"/>   
      <Button android:id="@+id/poslji"
            android:text="Pošlji"
            android:layout_height="wrap_content"
            android:layout_width="20dip"
            android:typeface="serif" android:textStyle="bold"
            android:layout_alignParentRight="true"
            android:layout_below="@id/nivo"
        android:layout_toRightOf="@id/nick"/>   

What i currently get is this: alt text

What is the appropriate layout_width for edittext and button?

A: 

As you are using something like a row to show the TextView, EditText and button, you can try to use TableLayout: http://developer.android.com/guide/tutorials/views/hello-tablelayout.html

Also, make sure you set android:layout_width="wrap_content" so that the EditText use as much space as possible.

Cristian
I tried using tablelayout befeore but had many problems because i have quite a few other views.
DixieFlatline
A: 

Try to assign equal weight to both button and edit text

Yeah, you're right about weight. As a hack you can do this. Not exactly right though.

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/aha4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="17dip"
        android:text="Vzdevek:" />
    <Button
        android:id="@+id/poslji"
        android:text="Pošlji"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:paddingLeft="40dip"
        android:paddingRight="40dip"
        android:typeface="serif"
        android:textStyle="bold"
        android:layout_alignParentRight="true" />
    <EditText
        android:id="@+id/nick"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_toRightOf="@id/aha4"
        android:layout_toLeftOf="@id/poslji" />
</RelativeLayout>
Alex Volovoy
Weight can't be assigned to relative layout.
DixieFlatline
You're right about that sorry.
Alex Volovoy
A: 

I managed to solve it with specifying minWidth and maxWidth for EditText.

DixieFlatline
A: 

Hi,

is there any possible way to apply style to the particular text in editText?

e.g:-- EditText Text: "This doubt i am facing from last month"

i.e. I want to apply the android:textStyle="bold" tag to selected text(i am facing) from edittext.

I am expecting this type of output: "This doubt i am facing from last month"

Thank you Jetti.

jetti