tags:

views:

261

answers:

2

dear friends,

i am facing issue that when i click on edittext its width gets changed i want to fix its width according to screen so that it covers whole screen and then button at right side of it.

here is the code

A: 

Hi,

You are missing android:layout_width="fill_parent" on the TableRow and EditText tags. Should look something like this:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:stretchColumns="2" android:orientation="horizontal">
    <TableRow android:layout_width="fill_parent">
        <EditText android:id="@+id/txtAdPost" android:layout_column="2"
            android:gravity="left" android:singleLine="True"
            android:layout_width="fill_parent" />
        <Button android:id="@+id/btnAdPost" android:gravity="left"
            android:layout_height="45px" android:layout_column="3" android:text="New Post" />
    </TableRow>
</TableLayout>
Klarth
no still same problem.... edittext changes its width after clicking on it..
UMMA
strange... I retried this view (as posted in my answer above) in isolation and I'm don't see the EditText field changing its width. I'm also not sure if the code that you pasted underneath your question is a direct copy and paste from your code, because I noticed there was a stray semicolon in the TableLayout tag and the xmln:android attribute was missing http:// (in XML of your commment). If not, it might help to look at how you are setting and using your view in your code or, even, how you are using this view. Which platform version are you also running it in?
Klarth
Actually, could this be what you were actually after? For EditText, in **addition** to adding **android:layout_width**, change **android:layout_column="2"** to **android:layout_column="0"** and add the attribute **android:layout_span="3"**.
Klarth
USING 2.0.1 version
UMMA
A: 

actually i was using RelativeLayout above

table which was causing problem

removing that solved my problem.

UMMA