ZoomInZoomOut扩展了imageView并允许用户使用手势拖动和放大图像,DrawView形成一个可调整大小的圆圈,这就是我想在用户按下按钮时显示的内容
以下是实现我所拥有的代码......
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_display);
Intent intent = getIntent();
String path = getIntent().getStringExtra(ImageDisplayActivity.KEY_PATH);
final Button button = (Button) findViewById(R.id.button1);
try {
java.io.FileInputStream in = this.openFileInput(path);
bitmap = BitmapFactory.decodeStream(in);
bitmap = bitmap.copy(bitmap.getConfig(), true);
touch = (ZoomInZoomOut)findViewById(R.id.IMAGEID);
touch = arrangeImageView(touch);
touch.setImageBitmap(bitmap);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendMessage(View view) {
// Do something in response to button click
shape = (DrawView)findViewById(R.id.IMAGEID2);
}
XML
<com.commonsware.android.test1.ZoomInZoomOut
android:id="@+id/IMAGEID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<com.commonsware.android.test1.DrawView
android:id="@+id/IMAGEID2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AddCircle"
android:id="@+id/button1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:onClick="sendMessage"/>
答案 0 :(得分:1)
一个VISIBLE
和另一个INVISIBLE