sunil_patidar
sunil_patidar

Reputation: 203

how to use multiple edittext on single image perfectlyy

enter image description here

i have to set 16 edittext in this image.i put this image in mdpi folder .calculate pixel to dp and set size for edittext accordinglly. my problem is when i tested it in my ASUS Fonepad it work perfectlly.but when i tested in galaxy tab size of first edittext end just before the line of first box. it makes big difference till i go the last edittext. please help. i have tried this code.

TableRow.xml
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/table_back" >

<EditText
    android:id="@+id/req"
    android:layout_width="78dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:paddingLeft="2dp" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/fg"
    android:layout_width="78dp"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:paddingLeft="2dp" />

<EditText
    android:id="@+id/erg"
    android:layout_width="78dp"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:paddingLeft="2dp" />

<EditText
    android:id="@+id/srop"
    android:layout_width="40dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:gravity="center_horizontal"
    android:inputType="number" />

<EditText
    android:id="@+id/caes"
    android:layout_width="78dp"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:paddingLeft="2dp" />

<EditText
    android:id="@+id/oc"
    android:layout_width="40dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:gravity="center_horizontal"
    android:inputType="number" />

<EditText
    android:id="@+id/process"
    android:layout_width="78dp"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:paddingLeft="2dp" />

<EditText
    android:id="@+id/dt"
    android:layout_width="39dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:gravity="center_horizontal"
    android:inputType="number" />

<TextView
    android:id="@+id/rpn"
    android:layout_width="39dp"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:gravity="center_horizontal" />

<EditText
    android:id="@+id/rec"
    android:layout_width="78dp"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:paddingLeft="2dp" />

<EditText
    android:id="@+id/sv2"
    android:layout_width="39dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:gravity="center_horizontal"
    android:inputType="number" />

<EditText
    android:id="@+id/oc2"
    android:layout_width="39dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:gravity="center_horizontal"
    android:inputType="number" />

<EditText
    android:id="@+id/dt2"
    android:layout_width="39dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:gravity="center_horizontal"
    android:inputType="number" />

<TextView
    android:id="@+id/new_rn"
    android:layout_width="39dp"
    android:layout_height="wrap_content"
    android:background="#00000000"

    android:gravity="center_horizontal" />

<EditText
    android:id="@+id/resp"
    android:layout_width="78dp"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:paddingLeft="2dp" />

<EditText
    android:id="@+id/target_date"
    android:layout_width="80dp"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:editable="false"
    android:gravity="center_horizontal" />

Upvotes: 0

Views: 66

Answers (1)

Pontus Backlund
Pontus Backlund

Reputation: 1017

You should use weight instead of dp. for example set weightsum on tablerow to a thousand and then divide up the weight on the EditTexts. This way you have more control than just relying on your calculations on dp. It could also be padding, look through dimensions and make sure that there is no padding or just override it by setting padding:0; on your tablerow

Upvotes: 1

Related Questions