imageview

Select a portion of image in ImageView and retrieve the end points of selected rectangle

白昼怎懂夜的黑 提交于 2019-11-26 19:55:40
问题 I need to drag and select a portion of an image set in an ImageView and retrieve the end points of the selected rectangle without causing any modifications (such as crop). So far all I've been able to do is figure out the co-ordinates of the point where the user taps the screen. ImageView imageView = (ImageView) findViewById(R.id.imageView); imageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { //Simply displays a toast

android imageView: setting drag and pinch zoom parameters

和自甴很熟 提交于 2019-11-26 19:47:34
I am currently developing for Android (my first app) an application which lets users see the subway map and be able to pinch zoom and drag around. I am currently modifying the code found in Hello Android, 3rd Edition and got the pinch zooming and dragging to work. I'm using Matrix as my layout scale. However I now have 3 problems: I tried many things to limit the drag parameters but I can't seem to stop it being dragged off the parent view (and can actually disappear from view). I've tried setting layout parameters in the XML file and it just doesn't work. I can pinch zoom fine but I have

Scaling ImageView to device width

半世苍凉 提交于 2019-11-26 19:31:46
问题 In my Android App I have a Activity which show images which have following size 244 x 330 . I want to show those images in full device width. My layout file looks like this: <?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 android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ImageView android:id="@

Full screen background image in an activity

孤人 提交于 2019-11-26 19:14:31
I see many applications that use a full-screen image as background. This is an example: I want to use this in a project, the best way I've found so far to do this is to use an image with a large size, put it in a ImageView and use android: adjustViewBounds="true" to adjust the margins The problem is that if a screen with a very high resolution, the image falls short. Another option I thought of is to use the image in a FrameLayout , with match_parent in width and height as background... this stretches the image, but I think the result is not very good. How would you do it? stinepike There are

Android: Generate random color on click?

北城以北 提交于 2019-11-26 18:28:19
I have an ImageView , in which I am programmaticly creating drawables and presenting them to the user. My goal is to click on said ImageView and change the drawable's color. How would I go about the random color changing bit? I am currently tinkering with Random() , Color.argb() and a few other things, but I can't seem to get it to work! Random rnd = new Random(); paint.setARGB(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); or Random rnd = new Random(); int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); view.setBackgroundColor(color); Though in your

How to give hexagon shape to ImageView

孤者浪人 提交于 2019-11-26 18:28:08
How to give hexagon shape to ImageView . Is it possible to do in same way ? If so then how. If this is not possible through this then how this could be achieved ? <shape xmlns:android="http//schemas.android.com/apk/res/android" android:shape="hexagon"> <solid android:color="#ffffffff" /> <size android:width="60dp" android:height="40dp" /> </shape> Screenshot Here I can't do masking image because I can not detect which portion of bitmap I should crop to get hexagon shape bitmap. So I am looking for the answer to give hexagon shape to ImageView Try this View. You might want to adjust it for your

How to place an imageview on top of another imageview in android

馋奶兔 提交于 2019-11-26 18:23:32
问题 This is my layout which i tried so far without any success <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/white"> <LinearLayout android:id="@+id/lltest" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerHorizontal="true"> <ImageView android:id="@+id/inside

Android: Drawing a canvas to an ImageView

て烟熏妆下的殇ゞ 提交于 2019-11-26 18:12:59
问题 I'm new to android programming and what I'm trying to figure out is this; In my layout i have a TextView, ImageView, and Button, all on a vertically oriented LinearLayout. I want to be able to dynamically draw circles in the ImageView, without disturbing the rest of my layout(textview/button). I'm trying to create a canvas, and use the drawcircle function within canvas to set the location of the circle. And then draw that canvas to my imageview in some way. I cannot get this to work, is there

How to prevent onClick method on transparent portion of a PNG-loaded ImageView

蓝咒 提交于 2019-11-26 18:11:29
问题 I am currently developing an Android app that displays multiple images (as ImageView's ) stacked on top of each other. Here is how the layers are currently configured: Background layer: scales the entire screen, must be clickable Foreground layer: scales the entire screen, must be clickable, contains transparency which allows the user to see some of the background layer The problem I face is with the foreground layer. I am assigning the onClick() method to the imageview, but the method is

Adding text to ImageView in Android

人走茶凉 提交于 2019-11-26 18:05:35
问题 I want to use an ImageView to show some message in a fancy way. So I want to add text to this ImageView . How to do that? 回答1: To add a text to your ImageView you can do this: <RelativeLayout> // Only works inside a RelativeLayout <ImageView android:id="@+id/myImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/myImageSouce" /> <TextView android:id="@+id/myImageViewText" android:layout_width="wrap_content" android:layout_height="wrap