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.

1 comment:

Golang: Http POST Request with JSON Body example

Go standard library comes with "net/http" package which has excellent support for HTTP Client and Server.   In order to post JSON ...