gpt4 book ai didi

android - Leanback 示例 Activity 崩溃

转载 作者:行者123 更新时间:2023-12-04 14:32:15 27 4
gpt4 key购买 nike

我从 android studio 添加了一个leanback 示例 Activity 。 Activity 因以下堆栈跟踪而崩溃。我没有修改代码,我看到默认添加的所有布局都定义了 layout_width 和 layout_height 参数。

java.lang.RuntimeException: Binary XML file line #21: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:608)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6485)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6654)
at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:741)
at android.support.v17.leanback.widget.BaseCardView$LayoutParams.<init>(BaseCardView.java:862)
at android.support.v17.leanback.widget.BaseCardView.generateLayoutParams(BaseCardView.java:817)
at android.support.v17.leanback.widget.BaseCardView.generateLayoutParams(BaseCardView.java:54)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:812)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v17.leanback.widget.ImageCardView.buildImageCardView(ImageCardView.java:165)
at android.support.v17.leanback.widget.ImageCardView.<init>(ImageCardView.java:156)
at android.support.v17.leanback.widget.ImageCardView.<init>(ImageCardView.java:282)
at android.support.v17.leanback.widget.ImageCardView.<init>(ImageCardView.java:275)
at com.amazon.bueller.photos.activity.CardPresenter$1.<init>(CardPresenter.java:55)
at com.amazon.bueller.photos.activity.CardPresenter.onCreateViewHolder(CardPresenter.java:55)
at android.support.v17.leanback.widget.ItemBridgeAdapter.onCreateViewHolder(ItemBridgeAdapter.java:312)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6290)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5478)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5363)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5359)
at android.support.v17.leanback.widget.GridLayoutManager.measureScrapChild(GridLayoutManager.java:1211)
at android.support.v17.leanback.widget.GridLayoutManager.processRowSizeSecondary(GridLayoutManager.java:1277)
at android.support.v17.leanback.widget.GridLayoutManager.onMeasure(GridLayoutManager.java:1374)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3012)
at android.view.View.measure(View.java:17935)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5548)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17935)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5548)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17935)
at android.support.v17.leanback.widget.GridLayoutManager.measureChild(GridLayoutManager.java:1466)
at android.support.v17.leanback.widget.GridLayoutManager$2.createItem(GridLayoutManager.java:1556)
at android.support.v17.leanback.widget.SingleRow.appendVisibleItems(SingleRow.java:111)
at android.support.v17.leanback.widget.Grid.appendVisibleItems(Grid.java:371)
at android.support.v17.leanback.widget.GridLayoutManager.appendVisibleItems(GridLayoutManager.java:1749)
at android.support.v17.leanback.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:1973)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3506)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3254)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3767)
at android.view.View.layout(View.java:16046)
at android.view.ViewGroup.layout

最佳答案

将“Theme.Leanback”作为样式添加到 Activity 中,错误就会消失。

例子:

<activity android:name="com.sample.activity.DetailsActivity"
android:theme="@style/Theme.Leanback"/>

关于android - Leanback 示例 Activity 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41472291/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com