【发布时间】:2018-05-07 09:32:27
【问题描述】:
谁能告诉我这个布局有什么问题?因为我似乎找不到任何可能导致 InflateException 的异常情况。此外,我主要在三星设备上遇到此异常,其他设备似乎或多或少都可以正常工作。完全异常
致命异常:java.lang.RuntimeException 无法启动活动 ComponentInfo{类名}:android.view.InflateException:二进制 XML 文件第 0 行:膨胀 {类名} 时出错
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/loginContainer"
style="@style/AuthenticationTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0">
<LinearLayout
android:id="@+id/holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="@string/window_enter_identifier_greeting_label"
android:textAlignment="center"
android:textSize="26sp" />
<TextView
android:id="@+id/info"
style="@style/AuthenticationTheme"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="@dimen/authentication_margin_from_sides"
android:layout_marginRight="@dimen/authentication_margin_from_sides"
android:gravity="center"
android:text="@string/window_enter_identifier_phone_description_label"
android:textAlignment="center"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/phoneInputHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.custom.authentication.views.IdentifierInputView
android:id="@+id/authenticationInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/authentication_margin_from_sides"
android:layout_marginRight="@dimen/authentication_margin_from_sides" />
</LinearLayout>
</LinearLayout>
<com.custom.authentication.views.BottomButtonsView
android:id="@+id/bottomButtons"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:linkText="@string/window_enter_identifier_login_with_email_button"
app:mainText="@string/Continue" />
</android.support.constraint.ConstraintLayout>
我在我的自定义视图类中扩展了这个布局,如下所示:
class EnterIdentifierView(context: Context) : ConstraintLayout(context) {
init {
inflate(context, R.layout.view_enter_identifier, this)
}
并像这样创建我的自定义视图:
override fun onCreateControllerView(layoutInflater: LayoutInflater, viewParent: ViewGroup) = EnterIdentifierView(layoutInflater.context)
【问题讨论】:
-
你能在你试图膨胀这个布局的地方添加代码吗,我们需要整个东西来帮助你:)。
-
@xoxel 我更新了我的帖子
标签: android xml android-constraintlayout inflate-exception