Error: Invalid layout param in a LinearLayout: layout_alignParentTop

The error "Invalid layout param in a LinearLayout: layout_alignParentTop or layout_centerHorizontal or layout_centerVertical or layout_alignParentLeft" occurs when you have declared the Linear Layout but included these layout parameters for the button, textview or any other layout element.

Removing these attribute such as "alignParentTop" declared for any of the layout element such as textview or button will resolve the error.

For an example you may get above error if you have declared linear layout as below:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="34dp"
        android:layout_marginTop="61dp"
        android:text="@string/hello_world" />
</LinearLayout>

To resolve the error remove lines marked in red.

Comments

  1. sweet:-) saved me a lot of frustration for sharing

    ReplyDelete

Post a Comment

Popular posts from this blog

How to boot Samsung Galaxy SL( GT-I9003) in recovery mode

How to flash CWM Recovery to Samsung Galaxy SL( GT-I9003) using Odin

How to Factory Reset or Hard Reset Samsung Galaxy SII ( GT-i9100)