imageview

Android code to fetch Image from server and display it in Imageview

孤者浪人 提交于 2019-12-18 09:41:53
问题 Hi I know how to fetch an string from jsonobject, but my question is how to fetch an image from Rest api and display it. The image is stored as profile_image in jsonobject My code: try { JSONObject jsonObject = new JSONObject(response); JSONObject object = jsonObject.getJSONObject("user"); String attr1 = object.getString("username"); data = "" + attr1; textView15.setText(data); if (object.has("profession")) { String attr2 = object.getString("profession"); data2 = "" + attr2; textView16

Detect multitouch with Ontouch listener Android

旧城冷巷雨未停 提交于 2019-12-18 09:26:59
问题 I currently have an imageview element that upon being touched, that tests if the action is an actiondown event, and if it is, it gets the coordinates of the touch with getraw(x or y) and then carries out an action based on those coordinates. How would I implement this to get two sets of coordinates from a two finger multitouch event? 回答1: Take a look at the ACTION_POINTER_DOWN action define in MotionEvent . This is the event that will get called when additional fingers come down after the

catch “RuntimeException: Canvas: trying to draw too large…”

三世轮回 提交于 2019-12-18 08:55:12
问题 I have an application which draws an image from the file system to screen like so: Bitmap image = BitmapFactory.decodeFile(file.getPath()); imageView.setImageBitmap(image); If the image is very large I see this error: java.lang.RuntimeException: Canvas: trying to draw too large(213828900bytes) bitmap. at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260) at android.graphics.Canvas.drawBitmap(Canvas.java:1415) ... The stack does not reach my code. How can I catch this

Overlay text over imageview in framelayout programmatically - Android

假如想象 提交于 2019-12-18 08:40:55
问题 I am trying to implement a textview over an image in a framelayout at the center and bottom of the layout as it is seen here: http://developer.android.com/resources/articles/layout-tricks-merge.html <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="center" android:src="@drawable/golden_gate" />

Overlay text over imageview in framelayout programmatically - Android

我是研究僧i 提交于 2019-12-18 08:40:03
问题 I am trying to implement a textview over an image in a framelayout at the center and bottom of the layout as it is seen here: http://developer.android.com/resources/articles/layout-tricks-merge.html <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="center" android:src="@drawable/golden_gate" />

Rotating ImageView in Android < API Level 11

左心房为你撑大大i 提交于 2019-12-18 08:24:26
问题 So in API Level 11 Google introduced the ability to rotate an ImageView (Yay, after they introduced the possibility to Animate such a rotation, yay smart thinking, yay!) But how should I go about to rotate an ImageView using e.g. API level 8? I can't use setRotation() as described above. 回答1: RotationAnimation was present since Api level 1 RotateAnimation animation = new RotateAnimation(from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator

Rotating ImageView in Android < API Level 11

梦想与她 提交于 2019-12-18 08:23:21
问题 So in API Level 11 Google introduced the ability to rotate an ImageView (Yay, after they introduced the possibility to Animate such a rotation, yay smart thinking, yay!) But how should I go about to rotate an ImageView using e.g. API level 8? I can't use setRotation() as described above. 回答1: RotationAnimation was present since Api level 1 RotateAnimation animation = new RotateAnimation(from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator

How do I save an ImageView as an image?

冷暖自知 提交于 2019-12-18 05:46:25
问题 I have an ImageView with a share intent( which works great, brings up all the apps I can share the image with), however, I can not share the photo because it has no path on my phone. How do I go about saving the ImageView on my phone? Below is my code. public void taptoshare(View v) { View content = findViewById(R.id.myimage); content.setDrawingCacheEnabled(true); Bitmap bitmap = content.getDrawingCache(); File file = new File("/DCIM/Camera/image.jpg"); try { file.createNewFile();

How to set random images to ImageView's?

亡梦爱人 提交于 2019-12-18 05:13:40
问题 i am using 9 image view's i want set images to imageview randomly , when I click on refresh button, but I tried like this it's working for random allocation of images but it's repeating the same image in two (or) three imageview's at a time. where is the problem in my code.. final int[] imageViews = { R.id.imgview11, R.id.imgview12, R.id.imgview13, R.id.imgview21, R.id.imgview22, R.id.imgview23, R.id.imgview31, R.id.imgview32, R.id.imgview33 }; final int[] images = { R.drawable.i1, R.drawable

Android draw border in ImageView

不羁的心 提交于 2019-12-18 05:02:36
问题 I want to draw a border around an image. But I can't align the border at the ImageView itself (like it is done mostly) because I translate and scale the image inside of the ImageView with the ImageMatrix (the ImageView itself is fill_parent / fills the whole screen). I had the idea to add a second image (which looks like a border) and translate & scale it in the same way as the image which should have a border, but it isn't very handy to do it this way. Has anybody a better idea to reach that