有人可以帮助我解决错误吗? 如何解决这个问题?
无法开始活动 “ ComponentInfo {com.example.name.myApp / com.example.dima.myApp.MainActivity}: android.view.InflateException:二进制XML文件第2行:错误 膨胀类android.widget.RelativeLayout“
这是我的activity_main:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/city">
<View
android:background="@drawable/rectangle_background"
android:layout_width="300dp"
android:layout_height="250dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:elevation="4dp"
app:layout_constraintVertical_bias="0.511"
android:id="@+id/view" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/>
<EditText
android:id="@+id/email"
android:layout_width="250dp"
android:layout_height="40dp"
android:inputType="textEmailAddress"
android:ems="10"
android:elevation="5dp"
android:hint="@string/email"
android:fontFamily="serif"
android:textColorHint="#000000"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="@drawable/rectangle_email"
app:layout_constraintStart_toStartOf="@+id/view"
app:layout_constraintEnd_toEndOf="@+id/view"
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="34dp"
app:layout_constraintVertical_bias="0.392" app:layout_constraintBottom_toBottomOf="@+id/view"
android:textSize="16sp"
android:layout_alignTop="@+id/view" android:layout_centerHorizontal="true"/>
<EditText
android:id="@+id/password"
android:layout_width="250dp"
android:layout_height="40dp"
android:inputType="textPassword"
android:ems="10"
android:elevation="5dp"
android:hint="@string/password"
android:fontFamily="serif"
android:textColorHint="#000000"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="@drawable/rectangle_email"
app:layout_constraintStart_toStartOf="@+id/view"
app:layout_constraintEnd_toEndOf="@+id/view"
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="25dp"
app:layout_constraintVertical_bias="0.677" app:layout_constraintBottom_toBottomOf="@+id/view"
android:textSize="16sp"
android:layout_below="@+id/email" android:layout_alignLeft="@+id/email"
android:layout_alignStart="@+id/email"/>
<Button
android:text="Sign in"
android:fontFamily="serif"
android:layout_width="180dp"
android:layout_height="40dp"
android:id="@+id/signIn"
android:background="@drawable/button"
android:elevation="5dp"
app:layout_constraintStart_toStartOf="@+id/view"
app:layout_constraintEnd_toEndOf="@+id/view" android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="@+id/password" app:layout_constraintBottom_toBottomOf="@+id/view"
app:layout_constraintVertical_bias="0.25"
android:layout_below="@+id/password" android:layout_centerHorizontal="true"/>
<TextView
android:text="@string/newAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:elevation="5dp"
android:id="@+id/newAccount" app:layout_constraintStart_toStartOf="@+id/view"
app:layout_constraintEnd_toEndOf="@+id/view"
app:layout_constraintTop_toBottomOf="@+id/signIn"
android:textSize="12sp" android:fontFamily="serif"
android:layout_below="@+id/signIn" android:layout_centerHorizontal="true" android:layout_marginTop="11dp"/>
<ImageView
android:src="@drawable/account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="5dp"
android:id="@+id/imageView" android:layout_marginTop="7dp"
app:layout_constraintTop_toTopOf="@+id/email" app:layout_constraintBottom_toBottomOf="@+id/email"
app:layout_constraintEnd_toEndOf="@+id/email"
android:layout_marginEnd="15dp" android:layout_alignTop="@+id/email" android:layout_alignRight="@+id/email"
android:layout_alignEnd="@+id/email" android:layout_marginRight="15dp"/>
<ImageView
android:src="@drawable/lock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="5dp"
android:id="@+id/imageView2"
app:layout_constraintTop_toTopOf="@+id/password" app:layout_constraintBottom_toBottomOf="@+id/password"
app:layout_constraintEnd_toEndOf="@+id/password"
android:layout_marginTop="7dp" android:layout_alignTop="@+id/password"
android:layout_alignLeft="@+id/imageView" android:layout_alignStart="@+id/imageView"/>
</RelativeLayout>
我只是想看看我在电话上的想法,看起来如何。 我的MainActivity没有任何动作:
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}