HELP in Android Studio: "Rendering Problems: One or more layouts are missing the layout_width or layout_height attributes"

0

I was looking at a tutorial for a side menu, and at the time of making the layout of "navigation_header" I see this rendering error. I'm following the tutorial to the letter and I do not know why it happened. I'm in version 2.1.2.

Here is the image of the error and the video link:

link

I followed the steps of the how to create it tutorial; that is, layout> New> Layout resource file , I named my layout and in Root element I put RelativeLayout , and in the tutorial it worked but not me.

In the properties I tried to modify them but in doing so, it is as if the property was deleted, but in text it appears like this, and that is the whole layout code :

PS: I already tried to change the API and the Android theme and it still gives me problems, some with fewer errors and others with more.

    
asked by Oscar Anibal 28.06.2018 в 00:22
source

1 answer

0

The error is indicated in the first image, layout_height and layout_width are values that have to be indicated in all the elements of a layout. The second image you say is all the code you have in the layout, if that all the code you have is impossible to work. The minimum that there must be in the text of a layout and that is created automatically when creating one is this, although with the new version it is a constraint_layout, I have given you the example of the relative_layout:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</RelativeLayout>

And for each new element that you create you have to give it the properties layout_width and layout_height, if it will not give you an error, here is an example of a RelativeLayout with a pair of elements:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <EditText android:id="@+id/TxtNombre"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:inputType="text" />

    <Button android:id="@+id/BtnAceptar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/TxtNombre"
        android:layout_alignParentRight="true" />
</RelativeLayout>
    
answered by 28.06.2018 / 02:05
source