Activity 必须是:AppCompatActivity
xml 中有:EditText,不能被继承
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image_view"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginBottom="12dp" />
<EditText
android:id="@+id/my_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:text="Hello World!"/>
</LinearLayout>
具体看:AppCompatViewInflater 的 createView方法
uml code
@startuml
'https://plantuml.com/sequence-diagram
AppCompatActivity --> AppCompatDelegateImpl : setContentView
AppCompatDelegateImpl --> LayoutInflater : inflate
LayoutInflater --> LayoutInflater : createViewFromTag
LayoutInflater --> LayoutInflater : tryCreateView
LayoutInflater --> AppCompatDelegateImpl : createView
AppCompatDelegateImpl --> AppCompatViewInflater : createView
@enduml