Layout stays blank

79 views Asked by At

I have added an ImageView and two TextFields to my Layout but when I look in the preview it just stays blank. It gives me the error "Rendering error". What can I do?

I will add my Layout file in the following:

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

<ImageView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:src="@drawable/wireless"
    android:layout_centerHorizontal="true"
    android:scaleType="centerCrop"
    android:layout_marginTop="150dp"
    android:id="@+id/img"
    />

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="@string/slide_1_title"
    android:textColor="android:color/white"
    android:textSize="30sp"
    android:textStyle="bold"
    android:gravity="center_horizontal"
    android:layout_below="@+id/img"
    android:layout_marginTop="12dp"
    android:id="@+id/slide_title"
    />
<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="@string/slide_1_desc"
    android:textColor="android:color/white"
    android:textSize="18sp"
    android:gravity="center_horizontal"
    android:layout_below="@id/slide_title"
    android:layout_marginTop="12dp"
    android:id="@+id/slide_desc"
    android:layout_marginRight="40sp"
    android:layout_marginLeft="40sp"
    />

</RealtiveLayout>
2

There are 2 answers

2
Viswa Sundhar On BEST ANSWER

Check this below changes:

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

<ImageView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:src="@drawable/wireless"
    android:layout_centerHorizontal="true"
    android:scaleType="centerCrop"
    android:layout_marginTop="150dp"
    android:id="@+id/img"
    />

<TextView
    android:layout_width="match_parent"
    android:layout_height="45dp"//or you use wrap_content
    android:text="@string/slide_1_title"
    android:textColor="android:color/white"
    android:textSize="30sp"
    android:textStyle="bold"
    android:gravity="center_horizontal"
    android:layout_below="@+id/img"
    android:layout_marginTop="12dp"
    android:id="@+id/slide_title"
    />
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/slide_1_desc"
    android:textColor="android:color/white"
    android:textSize="18sp"
    android:gravity="center_horizontal"
    android:layout_below="@id/slide_title"
    android:layout_marginTop="12dp"
    android:id="@+id/slide_desc"
    android:layout_marginRight="40sp"
    android:layout_marginLeft="40sp"
    />

</RelativeLayout>
6
KeLiuyue On

Change RealtiveLayout to RelativeLayout in your root Layout.