图片未在 imageview onelplus 中设置,棒棒糖

Image is not set in imageview onelplus , lollipop

我试图创建一个 tutorial like in zomato app,它在我测试过的所有手机上都能正常工作,除了 oneplus 设备,在 oneplus one 和 oneplus X 中,图像没有设置,图像视图是透明的。我尝试以编程方式和通过 xml 设置图像。 android 版本 lollipop 在这些设备中使用高分辨率图像是否有任何问题。

我的activity:

int ht,wi;
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_tutorial);

            Display display = getWindowManager().getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);
            int width = size.x;
            int height = size.y;
 wi = width *2/3;
        ht  = height * 3/5;

            ImageView wireframe = (ImageView) findViewById(R.id.wireframe);
            BitmapWorkerTask task = new BitmapWorkerTask(wireframe);
            task.execute(R.drawable.wireframe);


    }

    public static int calculateInSampleSize(
            BitmapFactory.Options options, int reqWidth, int reqHeight) {
        // Raw height and width of image
        final int height = options.outHeight;
        final int width = options.outWidth;
        int inSampleSize = 1;

        if (height > reqHeight || width > reqWidth) {

            final int halfHeight = height / 2;
            final int halfWidth = width / 2;

            // Calculate the largest inSampleSize value that is a power of 2 and keeps both
            // height and width larger than the requested height and width.
            while ((halfHeight / inSampleSize) > reqHeight
                    && (halfWidth / inSampleSize) > reqWidth) {
                inSampleSize *= 2;
            }
        }

        return inSampleSize;
    }
    public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
                                                         int reqWidth, int reqHeight) {

        // First decode with inJustDecodeBounds=true to check dimensions
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeResource(res, resId, options);

        // Calculate inSampleSize
        options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

        // Decode bitmap with inSampleSize set
        options.inJustDecodeBounds = false;
        return BitmapFactory.decodeResource(res, resId, options);
    }


    class BitmapWorkerTask extends AsyncTask<Integer, Void, Bitmap> {
        private final WeakReference<ImageView> imageViewReference;
        private int data = 0;

        public BitmapWorkerTask(ImageView imageView) {
            // Use a WeakReference to ensure the ImageView can be garbage collected
            imageViewReference = new WeakReference<ImageView>(imageView);
        }

        // Decode image in background.
        @Override
        protected Bitmap doInBackground(Integer... params) {
            data = params[0];
            Bitmap bitmap = decodeSampledBitmapFromResource(getResources(), data, wi, ht);
            return  bitmap;
        }

        // Once complete, see if ImageView is still around and set bitmap.
        @Override
        protected void onPostExecute(Bitmap bitmap) {
            if (imageViewReference != null && bitmap != null) {
                final ImageView imageView = imageViewReference.get();
                if (imageView != null) {
                    imageView.setImageBitmap(bitmap);
                }
            }
        }
    }

我的 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="match_parent"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="2">
                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:descendantFocusability="afterDescendants">
                      <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_marginTop="30dp">
                        <ImageView
                            android:id="@+id/wireframe"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:src="@drawable/wireframe"/>
                    </RelativeLayout>
                    <TextView
                        android:id="@+id/tutorial_skip"
                        android:onClick="onLogin"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="SKIP LOGIN"
                        android:padding="5dp"
                        android:layout_gravity="right"
                        android:layout_marginRight="16dp"
                        android:layout_marginTop="10dp"
                        android:textColor="#ffffff"
                        android:textSize="15dp"
                        android:textStyle="bold"/>
                </FrameLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_weight="3"
                android:id="@+id/bottom_layout"
                android:gravity="bottom"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:background="#ffffff">
             </LinearLayout>
         </LinearLayout>

我尝试加载的图像:

我使用分辨率低得多的新图像,现在在图像视图中显示图像