{"action":"created","issue":{"url":"https://api.github.com/repos/bumptech/glide/issues/3288","repository_url":"https://api.github.com/repos/bumptech/glide","labels_url":"https://api.github.com/repos/bumptech/glide/issues/3288/labels{/name}","comments_url":"https://api.github.com/repos/bumptech/glide/issues/3288/comments","events_url":"https://api.github.com/repos/bumptech/glide/issues/3288/events","html_url":"https://github.com/bumptech/glide/issues/3288","id":355103102,"node_id":"MDU6SXNzdWUzNTUxMDMxMDI=","number":3288,"title":"Use cached images to get smaller","user":{"login":"Jeffery336699","id":16848549,"node_id":"MDQ6VXNlcjE2ODQ4NTQ5","avatar_url":"https://avatars1.githubusercontent.com/u/16848549?v=4","gravatar_id":"","url":"https://api.github.com/users/Jeffery336699","html_url":"https://github.com/Jeffery336699","followers_url":"https://api.github.com/users/Jeffery336699/followers","following_url":"https://api.github.com/users/Jeffery336699/following{/other_user}","gists_url":"https://api.github.com/users/Jeffery336699/gists{/gist_id}","starred_url":"https://api.github.com/users/Jeffery336699/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jeffery336699/subscriptions","organizations_url":"https://api.github.com/users/Jeffery336699/orgs","repos_url":"https://api.github.com/users/Jeffery336699/repos","events_url":"https://api.github.com/users/Jeffery336699/events{/privacy}","received_events_url":"https://api.github.com/users/Jeffery336699/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-29T10:47:29Z","updated_at":"2018-09-05T11:35:21Z","closed_at":null,"author_association":"NONE","body":"```\r\ncom.github.bumptech.glide:glide:3.7.0\r\n```\r\n```\r\n public void load(Context context, String url, int resId, ImageView iv) {\r\n        Glide.with(BaseApplication.getInstance())\r\n                .load(url)\r\n                .fitCenter()\r\n                .diskCacheStrategy(DiskCacheStrategy.SOURCE)\r\n                .crossFade()\r\n                .placeholder(resId) // can also be a drawable\r\n                .error(resId) // will be displayed if the image cannot\r\n                .into(iv);\r\n    }\r\n```\r\n\r\n![20180829184308](https://user-images.githubusercontent.com/16848549/44782933-6b2ac800-abbb-11e8-9a09-4d228743b947.png)\r\n\r\nThe first load will become smaller, and it will be normal after refreshing.\r\nI dynamically set the aspect ratio of the image according to the width of the screen.\r\n```\r\npublic class ScaleImageView extends android.support.v7.widget.AppCompatImageView{\r\n\r\n\r\n    private float mImgWidth;\r\n    private float mImgHeight;\r\n\r\n    public ScaleImageView(Context context, AttributeSet attrs) {\r\n        super(context, attrs);\r\n        initScreen(context);\r\n    }\r\n\r\n    private void initScreen(Context context) {\r\n        WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);\r\n        DisplayMetrics outMetrics = new DisplayMetrics();\r\n        manager.getDefaultDisplay().getMetrics(outMetrics);\r\n        int screenWidth = outMetrics.widthPixels;\r\n        int screenHeight = outMetrics.heightPixels;\r\n\r\n        mImgWidth = (screenWidth - dip2px(context, 20)-dip2px(context,20*4)) / 2f;\r\n        mImgHeight =  180f * mImgWidth/330f;\r\n\r\n    }\r\n\r\n    @Override\r\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\r\n        super.onMeasure(widthMeasureSpec, heightMeasureSpec);\r\n        int measureW = MeasureSpec.makeMeasureSpec((int) mImgWidth, EXACTLY);\r\n        int measureH = MeasureSpec.makeMeasureSpec((int)mImgHeight, EXACTLY);\r\n        setMeasuredDimension(measureW, measureH);\r\n    }\r\n\r\n    public int dip2px(Context context, float dpValue) {\r\n        final float scale=context.getResources().getDisplayMetrics().density;//屏幕密度\r\n        return (int)(dpValue*scale+0.5f);\r\n    }\r\n}\r\n```\r\n```\r\n <com.zhuoyigou.dese.widget.ScaleImageView\r\n                android:layout_width=\"match_parent\"\r\n                android:layout_centerHorizontal=\"true\"\r\n                android:layout_height=\"@dimen/x60\"\r\n                android:src=\"@mipmap/ic_launcher\"\r\n                android:id=\"@+id/ivImagBg2\"\r\n                android:scaleType=\"centerInside\"\r\n                android:layout_marginTop=\"@dimen/x60\"\r\n                />\r\n```\r\n\r\nI would like to ask how to solve this problem, thank you\r\n"},"comment":{"url":"https://api.github.com/repos/bumptech/glide/issues/comments/418698615","html_url":"https://github.com/bumptech/glide/issues/3288#issuecomment-418698615","issue_url":"https://api.github.com/repos/bumptech/glide/issues/3288","id":418698615,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODY5ODYxNQ==","user":{"login":"stale[bot]","id":26384082,"node_id":"MDM6Qm90MjYzODQwODI=","avatar_url":"https://avatars3.githubusercontent.com/in/1724?v=4","gravatar_id":"","url":"https://api.github.com/users/stale%5Bbot%5D","html_url":"https://github.com/apps/stale","followers_url":"https://api.github.com/users/stale%5Bbot%5D/followers","following_url":"https://api.github.com/users/stale%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/stale%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/stale%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stale%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/stale%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/stale%5Bbot%5D/repos","events_url":"https://api.github.com/users/stale%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/stale%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2018-09-05T11:35:21Z","updated_at":"2018-09-05T11:35:21Z","author_association":"NONE","body":"This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.\n"}}
{"actor":{"display_login":"stale"}}