我需要在我的形式,宽度是高度的两倍(1:2)当我调整大小 我怎么能这样做?谢谢你的帮助,对不起我的英文:)
我有一个应用程序,可以下载并显示来自URL的图像.这很好用
URLConnection conn = urls[i].openConnection();
conn.connect();
if(conn.getContentLength() > 0)
is = conn.getInputStream();
bis = new BufferedInputStream(is);
Bitmap temp = BitmapFactory.decodeStream(bis);
Run Code Online (Sandbox Code Playgroud)
我注意到WebView的下载和显示图像比上面的代码快得多,所以我想我会尝试.
String url = "http:\\image.jpg"
int mWidth = getSystemService(Context.WINDOW_SERVICE).getDefaultDisplay().getWidth()
webView.loadData("<html><body> <img src=\"" + url + "\" width=\"" + mWidth + "px\" height=\"auto\"></body></html>", "text/html", null);
Run Code Online (Sandbox Code Playgroud)
虽然这样可以更快地获得图像,但是它不会将图像缩放到屏幕大小,因此大图像总是超出WebView的宽度并需要滚动才能正常查看.
有谁知道如何解决问题,以便在WebView中正确显示图像或如何加快图像的下载速度?
我希望加速下载,但如果我可以正确缩放图像,我很乐意使用WebView.
我正在使用以下代码缩放我的webview以使内容适合屏幕的宽度:
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
Run Code Online (Sandbox Code Playgroud)
这有效,但现在我在内容的底部得到一个空白区域.空白空间的大小(高度)与其正在进行的缩放的大小成正比.因此对于较小的设备,尺寸更大.
我的感觉是在缩放生效后没有重新计算滚动条大小.这个假设是由于当通过点击屏幕放大和缩小时,空的空间消失了.虽然这适用于Android 2.3但不适用于4.0.
我的问题是如何在缩放后强制滚动条重新计算.还是有其他解决方案.
谢谢.
PS以下是我在xml中定义webview的方法
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/web_view"
android:background="#AAFFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我正在缩放视频并应用这样的水印:
ffmpeg -ss 0:0:0.000 -i video.mp4 -y -an -t 0:0:10.000
-vf \"[in]scale=400:316[middle]\" -b:v 2000k -r 20
-vf 'movie=watermark.png,pad=400:316:0:0:0x00000000 [watermark];[middle] [watermark]overlay=0:0[out]'
out.flv
Run Code Online (Sandbox Code Playgroud)
但是,应用的水印似乎缩放到原始视频大小而不是缩小的缩放视频大小.
此命令行适用于ffmpeg版本0.8.6.git,现在升级到版本后行为有所不同N-52381-g2288c77.
我如何让它再次运作?
我需要一个可以在x,y或两个方向上缩放的Pinch识别器,具体取决于收缩的方向.我在这里查看了许多其他问题,他们只有部分答案.这是我使用自定义UIPinchGestureRecognizer的完整解决方案.
是否可以在每个方向上按任意因子缩放RectF对象?在实践中,我将调整RectF的2倍大小(如果RectF为200X200,则我将其变为100x100)
有没有办法在运行时使用libGDX的粒子系统缩放粒子效果?
我知道关于这个问题的这个问题,但它没有解决运行时的缩放问题.我尝试使用Viktor的答案,但它只是让粒子效果一起消失.这是我尝试使用的代码:
ParticleEffect pe;
//Scale particle
for(ParticleEmitter emitter : pe.getEmitters())
{
float scaling = emitter.getScale().getHighMax();
emitter.getScale().setHigh(scaling * scale);
scaling = emitter.getScale().getLowMax();
emitter.getScale().setLow(scaling * scale);
scaling = emitter.getVelocity().getHighMax();
emitter.getVelocity().setHigh(scaling * scale);
scaling = emitter.getVelocity().getLowMax();
emitter.getVelocity().setLow(scaling * scale);
}
pe.setPosition(x, y);
pe.draw(spriteBatch, delta);
Run Code Online (Sandbox Code Playgroud)
如果没有中间的缩放代码,它会渲染得很好,只是没有缩放.
我正在使用ImageView的Zoom效果,所以我需要使用scaletype = matrix.现在,我想将中心位置设置为ImageView,但我无法设置它.
请帮我解决这个问题.
layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/imgdesc"
android:scaleType="matrix"
android:src="@drawable/ic_answer" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我试图在搅拌机中移动网格,以便最低的z点是z = 0.这将使最低点位于Z = 0平面上.这比较困难,因为我首先通过其最大轴来缩放模型.这不仅仅是我正在使用的一个案例,所以我试图让这个工作适用于任何单个网格模型.
这是我目前的尝试:
mesh_obj = bpy.context.scene.objects[0]
# I first find the min and max of the mesh. The largest and smallest points on the Z-axis
max_floats = [mesh_obj.data.vertices[0].co[0], mesh_obj.data.vertices[0].co[1], mesh_obj.data.vertices[0].co[2]]
min_floats = [mesh_obj.data.vertices[0].co[0], mesh_obj.data.vertices[0].co[1], mesh_obj.data.vertices[0].co[2]]
for vertex in mesh_obj.data.vertices:
if vertex.co[0] > max_floats[0]:
max_floats[0] = vertex.co[0]
if vertex.co[0] < min_floats[0]:
min_floats[0] = vertex.co[0]
if vertex.co[1] > max_floats[1]:
max_floats[1] = vertex.co[1]
if vertex.co[1] < min_floats[1]:
min_floats[1] = vertex.co[1]
if vertex.co[2] > max_floats[2]:
max_floats[2] = vertex.co[2]
if vertex.co[2] < …Run Code Online (Sandbox Code Playgroud) 我有一个RadioGroup我试图缩小,因为它太大了.所以我使用setScaleX()并setScaleY()缩小它.
它可以工作,但问题是当我缩放时,视图会改变X和Y的位置.我希望它在缩放后保持相同的左上角坐标.如何在缩放后使View保持不变?
见下面的代码:
CSRadioButton radiobutton = (CSRadioButton) field;
RadioGroup rg = new RadioGroup(this);
rg.setOrientation(RadioGroup.VERTICAL);
JSONArray choices = radiobutton.getChoices();
for(int j = 0; j < choices.length(); j++){
JSONObject currObj = choices.getJSONObject(j);
String text = currObj.getString("text");
RadioButton rb = new RadioButton(this);
rb.setText(text);
rg.addView(rb);
}
rscroll.addView(rg, lp);
rg.setScaleX(0.7f);
rg.setScaleY(0.7f);
Run Code Online (Sandbox Code Playgroud)