android-imageview

Android ImageView: How can I get the current rotation angle?

回眸只為那壹抹淺笑 提交于 2019-12-23 20:08:39
问题 I rotate an image view to point an arrow in the desired direction. Before performing the next rotation (using RotateAnimation), how can I get the currently rotated angle of the ImageView? Thanks 回答1: You need store your previous rotation angle in some variable. 回答2: Save rotate angle: ImageView arrow = (ImageView) findViewById(R.id.arrow); float x = arrow.getPivotX(); float y = arrow.getPivotY(); RotateAnimation anim = new RotateAnimation(arrowRotateStartAngle, arrowRotateXAngle, arrow

Image reloaded when scroll listView in android

笑着哭i 提交于 2019-12-23 16:24:01
问题 I am trying write a news list application. I had parsed JSON data from Server and created CustomListAdapter. There are three textView and imageView in my listView. It works great, image loaded and I set it to imageView. When scroll list view images are reloaded from server. This is my Fragment: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.news_fragment, container, false); this

How to check if android.hardware.Camera is released?

萝らか妹 提交于 2019-12-23 10:56:06
问题 I got an exception while releasing camera object "java.lang.RuntimeException: Method called after release" following is my code and exception stack trace. if (camera != null) { camera.stopPreview(); camera.release(); camera = null; } Exception stack trace - java.lang.RuntimeException: Method called after release() Thread[main,5,main] android.hardware.Camera._stopPreview(Native Method) android.hardware.Camera.stopPreview(Camera.java:626) com.s5.selfiemonkey1.activity.Preview.surfaceDestroyed

Android Dash/doted line issue?

随声附和 提交于 2019-12-23 07:36:36
问题 When I am using android dotted line its working fine in Small screens , but not working in Samsung S3 device and higher versions . Screenshots And drawable/dashline.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:dashWidth="20sp" android:dashGap="20sp" android:width="2dp" android:color="#FF0000" /> </shape> XML <ImageView android:id="@+id/button1" android:layout_width="fill_parent" android

Android Dash/doted line issue?

瘦欲@ 提交于 2019-12-23 07:34:11
问题 When I am using android dotted line its working fine in Small screens , but not working in Samsung S3 device and higher versions . Screenshots And drawable/dashline.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:dashWidth="20sp" android:dashGap="20sp" android:width="2dp" android:color="#FF0000" /> </shape> XML <ImageView android:id="@+id/button1" android:layout_width="fill_parent" android

Android orientation change causes things to disappear

守給你的承諾、 提交于 2019-12-23 06:07:03
问题 Below is my layout for the row template in a SimpleCursorAdapter. The ImageView with id next_arrow disappears permanently on orientation change (going back to original orientation doesn't make it re-appear). If I replace @drawable/arrow with @drawable/icon (copy of the standard sym_def_app_icon) it works fine. All the drawables in question are simple references to PNG files . I thought it might be somehow related to the icons being of different dimensions, but I resized @drawable/icon to be

Programmatically line up two views at a corner

纵饮孤独 提交于 2019-12-23 06:04:36
问题 So this seems like a very simple question, but I can't figure out how to get the proper location after scaling a view. I'm trying to line up an imageView to the bottom right corner of another imageView. This code works fine if I don't modify firstImageView . secondImageView.setX(firstImageView.getRight()); secondImageView.setY(firstImageView.getBottom()); But then after I apply a translation or scale to the firstImageView, the code above doesn't seem to work correctly (doesn't line up at

Android: Right-Aligning ImageView in LinearLayout

爱⌒轻易说出口 提交于 2019-12-23 05:26:40
问题 The imageView is not getting right-aligned in this linearlayout (If it matters this LinearLayout is actually a row in a list). But if i use a TextView (its commented in code below) instead of ImageView, it successfully gets right-aligned. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:background="#FFFFAA" android:orientation="horizontal" > <TextView android:id="@+id/txtTitle" android

Android+Java get image from URL on server and pass as string to client: Base64 decode and encode not working

喜欢而已 提交于 2019-12-23 02:30:10
问题 In Java server I fetch image from external service URL like: InputStream in = new java.net.URL(imageWebServiceURL).openStream(); String resultToCleint = org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(IOUtils.toByteArray(in)); Then on Android I parse it like: byte[] imageAsBytes = Base64.decode(resultToCleint.getBytes(), Base64.DEFAULT); imageView.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)); Result: Image not displayed, ain't errors

OnTouchListener intercept when touch goes outside view

核能气质少年 提交于 2019-12-23 01:38:09
问题 I have an ImageView that represent a button, and a relative OnTouchListener for change image inside it (for simulate pression on it) and launch a task: @Override public boolean onTouch(View v, MotionEvent event) { ImageView button = (ImageView) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { //change imageview image with pressed button return true; } case MotionEvent.ACTION_UP: { //change imageview image, and do a task return true; } } return false; } Now this two events are