当前位置: 动力学知识库 > 问答 > 编程问答 >

image processing - Display larger ruler on android scroll view

问题描述:

I do have long ruler image (shown below) that I need to use as scrollable view on android device.

Can some one please advice for the best way to do the same?

I tried this in two ways,

Initially I tried to put image as background to scroll view but that didn't work as image is too long/large.

Currently I am trying to use BitMap class to crop my image and use the part what I want to display. But again an issue is on every scroll need to crop another part of image and display the same such a way that it will not reflect on screen.

setContentView(R.layout.activity_demo);

ImageView image = (ImageView) findViewById(R.id.imgScaleFirst);

Options opts = new Options();

opts.inDither = true;

opts.inPreferredConfig = Bitmap.Config.ALPHA_8;

opts.inScaled = false; /* Flag for no scalling */

/* Load the bitmap with the options */

//Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.lbs_ruler_vert_left,opts);

Bitmap bmap= BitmapHelper.decodeFile(getResources().openRawResource(R.drawable.lbs_ruler_vert_left),182, 4096, true);

image.setImageBitmap(bmap);

I appreciate your input/idea for same.

网友答案:

Please check https://dhingrakimmi.wordpress.com/2015/09/17/android-measurment-scale-my-scale/?preview_id=2 This will show scale without any limit.

网友答案:

I found this link while searching for a similar requirement to draw a ruler. Hope this helps someone in future.

https://code.google.com/p/ruler-android/source/browse

The idea here is to create a custom view and use canvas to draw lines at appropriate intervals.

分享给朋友:
您可能感兴趣的文章:
随机阅读: