我目前正在为Android(我的第一个应用程序)开发一个应用程序,它可以让用户看到地铁地图,并能够捏缩放和拖动.
我目前正在修改Hello Android,3rd Edition中的代码,并进行了缩放缩放和拖动工作.我正在使用Matrix作为我的布局比例.
但是我现在有3个问题:
我尝试了很多东西来限制拖动参数,但我似乎无法阻止它被拖离父视图(并且实际上可以从视图中消失).我已经尝试在XML文件中设置布局参数,但它不起作用.
我可以捏缩放,但我又遇到了麻烦,限制了变焦量.我正在尝试设置max_zoom和min_zoom以限制缩放值(我将在之后发布我的代码)
我也很难尝试在我的图像上映射坐标,以便人们可以点击某些部分(这一点的全部意义是让用户点击地图上的一个工作站并查看有关它的信息)
我有一种感觉我遇到了麻烦,因为我正在使用矩阵比例.
这是我目前的代码:
Touch.java
package org.example.touch;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.os.Bundle;
import android.util.FloatMath;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.GridView;
import android.widget.ImageView;
public class Touch extends Activity implements OnTouchListener {
private static final String TAG = "Touch";
private static final float MIN_ZOOM = 1.0f;
private static final float MAX_ZOOM = 5.0f;
// These matrices will be used to move and zoom image
Matrix matrix = …Run Code Online (Sandbox Code Playgroud) 我正在使用一个代码,通过使用canvas将图像组合成1.我向ImageView显示图像看起来很好.但是当我尝试向WebView显示它时,它会向该图像显示背景黑色.我尝试更改HTML中的背景颜色,但它不会改变颜色.或透明.有人可以帮忙吗?结果在这里上面的图像在ImageView中,下面是在WebView中.
public class MyBimapTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img1 = (ImageView) findViewById(R.id.ImageView01);
img1.setVisibility(View.INVISIBLE);
Drawable dra1 = img1.getDrawable();
Bitmap map1 = ((BitmapDrawable) dra1).getBitmap();
ImageView img2 = (ImageView) findViewById(R.id.ImageView02);
img2.setVisibility(View.INVISIBLE);
Drawable dra2 = img2.getDrawable();
Bitmap map2 = ((BitmapDrawable) dra2).getBitmap();
// ***
ByteArrayOutputStream baos = new ByteArrayOutputStream();
map1.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
String abc = Base64.encodeBytes(b);
byte[] byt = null;
try { …Run Code Online (Sandbox Code Playgroud)