改变图像大小王氏的jQuery王氏、图像、大小、jQuery

2023-09-07 11:54:53 作者:我只是你指尖的沙

我有DIV ID MYIMAGE下的图像。现在我想用变化来调整其大小。我从选择框,如果要选择700X7000然后图像的大小将是高度700像素,宽700像素。随着出重新加载页面。任何一个可以帮助我,我该怎么办呢?

I have a image under div id myimage. Now I want to resize it by using change. I want from select box if selected 700X7000 then image's size will be height 700px and width 700px. With out reloading the page. Can any one help me how can I do this?

推荐答案

设置新的新的LayoutParams(200,200)每次

screenDensity = getResources().getDisplayMetrics().density;
dimInDP = 200 * (screenDensity/(float)160)
imageTextView.setLayoutParams(new LinearLayout.LayoutParams(dimInDP ,dimInDP ));

编辑: Android系统采用160dpi为密度独立像素计算的参考密度。例如,你的情况,你需要维度200dp。该系统以这个作为你想屏幕像素密度160dpi的设备上numbersof像素。因此,在运行时,它缩放相对于参考密度宽度。搜索结果假设你在一个屏幕密度120.宽度将被调整到150个物理像素乌尔运行应用程序。

EDIT : The Android system takes 160dpi as the reference density for density independent pixel calculation. For example, in your case you need dimension as 200dp. The system takes this as the numbersof pixels you want on a device of screen density 160dpi. So at runtime it scales the width relative to the reference density. Assume you run ur app on a screen density 120. The view width will be scaled to 150 physical pixels.