无法放大巴士路线图(Unable to zoom in the bus route map)
我有一个巴士路线图作为图像。 使用缩放控制器图像缩小但不放大请查看我的代码,让我知道要做的更改让它工作..我正在开发我的应用程序姜饼即API 10
import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.ZoomControls; public class Busmaps extends Activity { ImageView img; ZoomControls zoom; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.busmaps); img = (ImageView) findViewById(R.id.imageViewmaps1); zoom = (ZoomControls) findViewById(R.id.zoomControls1); zoom.setOnZoomInClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int w = img.getWidth(); int h = img.getHeight(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w + 50, h + 50); params.addRule(RelativeLayout.CENTER_IN_PARENT); img.setLayoutParams(params); } }); zoom.setOnZoomOutClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int w = img.getWidth(); int h = img.getHeight(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w - 50, h - 50); params.addRule(RelativeLayout.CENTER_IN_PARENT); img.setLayoutParams(params); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.bus_map_zoom, menu); return true; } }我的xml说公交路线图片: -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageViewmaps1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/map" /> <ZoomControls android:id="@+id/zoomControls1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> </RelativeLayout>我应该如何使我的变焦控制适用于放大和缩小。
i have a bus route map as an image. using the zoom controller the image is zooming out but not zooming in please look at my code and let me know the change to be done make it working.. i am developing my app on Gingerbread i.e API 10
import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.ZoomControls; public class Busmaps extends Activity { ImageView img; ZoomControls zoom; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.busmaps); img = (ImageView) findViewById(R.id.imageViewmaps1); zoom = (ZoomControls) findViewById(R.id.zoomControls1); zoom.setOnZoomInClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int w = img.getWidth(); int h = img.getHeight(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w + 50, h + 50); params.addRule(RelativeLayout.CENTER_IN_PARENT); img.setLayoutParams(params); } }); zoom.setOnZoomOutClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int w = img.getWidth(); int h = img.getHeight(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w - 50, h - 50); params.addRule(RelativeLayout.CENTER_IN_PARENT); img.setLayoutParams(params); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.bus_map_zoom, menu); return true; } }my xml says for bus route image:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageViewmaps1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/map" /> <ZoomControls android:id="@+id/zoomControls1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> </RelativeLayout>how should i make my zoom control working for both Zoom in and Zoom out.
更多推荐
发布评论