gpt4 book ai didi

android - 在 Android 版本 6 棉花糖中膨胀类 de.hdodenhof.circleimageview.CircleImageView 时出错

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:49:02 24 4
gpt4 key购买 nike

我创建了一个使用此 hdodenhof CircleImageview 库的应用程序。我的应用程序在 Android 7 和 7.1 上运行良好,但在较低版本(例如 marshmallow/Android 6)中会崩溃。我该如何解决这个问题?我已阅读他的 GitHub 帖子,但它并没有解决我的问题,因为人们要求从 .xml 中删除属性,但我没有使用这些属性。

这是我对 CircleImageView 的简单实现:

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/civ_requests"
android:layout_width="80sp"
android:layout_height="80sp"
android:layout_margin="10sp"
android:src="@drawable/profilesvg" />

这里是错误:

FATAL EXCEPTION: main
Process: com.milind.locatemymate, PID: 4288
android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class de.hdodenhof.circleimageview.CircleImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.milind.locatemymate.Fragment.Requests$1.onCreateViewHolder(Requests.java:152)
at com.milind.locatemymate.Fragment.Requests$1.onCreateViewHolder(Requests.java:103)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5869)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3225)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1632)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)

friends fragment 中的相同错误,这是其更新后的 xml 布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:src="@drawable/profilesvg"
android:id="@+id/civ_friend"
android:layout_width="80dp"
android:layout_height="80dp" />

<LinearLayout
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:textStyle="bold"
android:textColor="@color/LightBlack"
android:id="@+id/tv_friendName"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:textColor="@color/LightBlack"
android:layout_marginTop="5dp"
android:id="@+id/tv_friendStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<View
android:layout_marginTop="5dp"
android:background="@color/LightGrey"
android:layout_width="match_parent"
android:layout_height="0.5dp" />
</LinearLayout>

最佳答案

我也面临同样的问题,宽度和高度是“dp”。但是,在我这边,它通过将 scaleType 从 fitcenter 替换为 centerCrop 来解决。

关于android - 在 Android 版本 6 棉花糖中膨胀类 de.hdodenhof.circleimageview.CircleImageView 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50086459/

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