Sachin Gurnani
Sachin Gurnani

Reputation: 2444

This TableLayout layout or its LinearLayout parent is useless how to resolve from this warning

I have tablelayout inside linearlayout but it shows me this warning message
This TableLayout layout or its LinearLayout parent is useless how to overcome from this warning can ane help me . Thanks in advance

<?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent" >

          <TableLayout>

            <TableRow
                android:id="@+id/tableRow3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center" >

                <TextView
                    android:id="@+id/txtPass"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:text="Password"
                    android:textSize="18sp"
                    android:width="100dp" />

                <EditText
                    android:id="@+id/edPass"
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"
                    android:password="true" >

                    <requestFocus />
                </EditText>
              </TableRow>
          </TableLayout>

      </LinearLayout>

Upvotes: 4

Views: 18068

Answers (4)

user1515993
user1515993

Reputation: 69

Remove the TableLayout tags and put the attributes into the TableRow tags.

Upvotes: 1

EisenMurphy
EisenMurphy

Reputation: 11

Through the warning, the system just wants to say you have the space to optimize your layout code.There is no need to care much about it if you do not want to optimize your code now.

Upvotes: 1

droid1001
droid1001

Reputation: 41

If are looking for layout as below then the xml is as follows

Password_layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" 
    android:gravity="center">
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Password" />
<EditText
        android:layout_marginLeft="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Password" />


</LinearLayout>

Upvotes: 0

kosa
kosa

Reputation: 66657

Why do you need top most LinearLayout when you dont have anything inside LinearLayout except TableLayout? One of these layout should be enough. Remove either LinearLayout (or) TableLayout. That should resolve the issue.

Upvotes: 8

Related Questions