Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 荣誉6x中的问题不可见项(带StaggedGridLayoutManager的Recyclerview)_Android_Android Layout_Android Recyclerview_Adapter_Staggeredgridlayoutmanager - Fatal编程技术网

Android 荣誉6x中的问题不可见项(带StaggedGridLayoutManager的Recyclerview)

Android 荣誉6x中的问题不可见项(带StaggedGridLayoutManager的Recyclerview),android,android-layout,android-recyclerview,adapter,staggeredgridlayoutmanager,Android,Android Layout,Android Recyclerview,Adapter,Staggeredgridlayoutmanager,我使用的是Recyclerview,其层为StaggedGridLayoutManager。问题是,在大多数手机中,项目都会显示,但在荣誉6x手机中,项目不会显示,但可以单击 我将项目旋转Y:180设置为从右向左显示。 我甚至使用了GridLayoutManager,但它仍然存在同样的问题 所有手机的屏幕截图 在荣誉6x手机上 Recyclerview小部件 public class AutoFitGridRecyclerView extends RecyclerView {

我使用的是Recyclerview,其层为StaggedGridLayoutManager。问题是,在大多数手机中,项目都会显示,但在荣誉6x手机中,项目不会显示,但可以单击

我将项目旋转Y:180设置为从右向左显示。

我甚至使用了GridLayoutManager,但它仍然存在同样的问题

所有手机的屏幕截图

在荣誉6x手机上

Recyclerview小部件

    public class AutoFitGridRecyclerView extends RecyclerView {
    private StaggeredGridLayoutManager manager;
    private int columnWidth = -1;

    public AutoFitGridRecyclerView(Context context) {
        super(context);
        init(context, null);
    }

    public AutoFitGridRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public AutoFitGridRecyclerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        if (attrs != null) {
            // list the attributes we want to fetch
            // columnWidth is what GridView uses, so we use it too
            int[] attrsArray = {
                    android.R.attr.columnWidth
            };

            TypedArray array = context.obtainStyledAttributes(attrs, attrsArray);

            //retrieve the value of the 0 index, which is columnWidth
            columnWidth = array.getDimensionPixelSize(0, -1);
            array.recycle();
        }

        manager = new StaggeredGridLayoutManager(AppController.NumberColumnAutoFitForRecyclerViewForGridList(120), 1);
        setLayoutManager(manager);
    }

    @Override
    protected void onMeasure(int widthSpec, int heightSpec) {
        super.onMeasure(widthSpec, heightSpec);

        if (columnWidth > 0) {
            //The spanCount will always be at least 1
            int spanCount = Math.max(1, getMeasuredWidth() / columnWidth);
            manager.setSpanCount(spanCount);
        }
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return super.dispatchTouchEvent(ev);
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bRow"
    android:layout_width="110dp"
    android:layout_height="110dp"
    android:layout_marginTop="5dp"
    android:background="@android:color/transparent"
    android:clickable="true"
    android:focusable="true"
    android:gravity="center"
    android:orientation="vertical"
    android:rotationY="180">

    <com.balysv.materialripple.MaterialRippleLayout xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        android:focusable="true"
        app:mrl_rippleAlpha="0.2"
        app:mrl_rippleColor="@color/colorPrimary"
        app:mrl_rippleDuration="350"
        app:mrl_rippleOverlay="true"
        app:mrl_rippleRoundedCorners="100dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/layoutTitle">

                <ImageView
                    android:id="@+id/imgIcon"
                    android:layout_width="65dp"
                    android:layout_height="65dp"
                    android:layout_centerInParent="true"
                    android:padding="12dp" />

                <com.mrsanad.Application.Widgets.BadgeTextView
                    android:id="@+id/tvCount"
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_centerInParent="true"
                    android:gravity="center"
                    android:padding="0.5dp"
                    android:textColor="@color/White"
                    android:textSize="@dimen/SmallTextSize" />

            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/layoutTitle"
                android:layout_width="match_parent"
                android:layout_height="39dp"
                android:layout_alignParentBottom="true">

                <com.mrsanad.Application.Widgets.PersianTextViewBold
                    android:id="@+id/tvTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_marginLeft="2dp"
                    android:layout_marginRight="2dp"
                    android:gravity="center"
                    android:maxLines="2"
                    android:textColor="@color/Gray"
                    android:textSize="@dimen/SmallTextSize" />

            </RelativeLayout>

        </RelativeLayout>

    </com.balysv.materialripple.MaterialRippleLayout>
</LinearLayout>
活动内布局

<com.mrsanad.Application.Widgets.AutoFitGridRecyclerView
            android:id="@+id/gridMenu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="10dp"
            android:rotationY="180" />
你应该换成

ConstraintLayout允许您使用 平面视图层次(无嵌套视图组)。类似于 相对性,即所有视图都是根据 同级视图和父布局之间的关系,但它是 比RelativeLayout更灵活,更易于与Android一起使用 工作室的布局编辑器

您可以使用而不是dp。此大小单位随屏幕大小缩放。它可以帮助Android开发者支持多屏幕

dependencies {
  implementation 'com.intuit.sdp:sdp-android:1.0.6'
}
你的价值将是

    android:layout_width="@dimen/_100sdp"
    android:layout_height="@dimen/_100sdp"
    android:layout_marginTop="@dimen/_5sdp"
    
供参考 你可以使用。这是一个由bumptech开发的Android图像加载器库,也是谷歌推荐的库

Glide是一种快速高效的开源媒体管理和镜像工具 加载Android框架,包装媒体解码、内存和 磁盘缓存和资源池成为一种简单易用的方式 接口

Gradle

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.11.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}

我假设您正在从drawable加载图像资源。在这种情况下,您应该检查荣誉6x当前运行的是哪个版本?同时还要检查您正在加载的资源是否也在适当的屏幕密度大小文件夹中。

什么android版本支持6x?android 6.0(棉花糖),可升级到7.0(牛轧糖)**这很重要吗?***@javaddeb解决了这个问题?没有@intellijamiya你读过这个问题吗?我的问题是它根本不显示该项目,但您可以单击item@MohammadSalmanian显示您的
AppController.SetPicUrl
方法。你可以使用Glide,我使用毕加索,它也不显示TextView。
    android:layout_width="@dimen/_100sdp"
    android:layout_height="@dimen/_100sdp"
    android:layout_marginTop="@dimen/_5sdp"
    
RequestManager requestManager = Glide.with(contextObj);
RequestBuilder requestBuilder = requestManager.load(item.ImagePath);
requestBuilder.into(holder.imgIcon);
dependencies {
  implementation 'com.github.bumptech.glide:glide:4.11.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}