imageview

android: stretch image in imageview to fit screen

给你一囗甜甜゛ 提交于 2019-11-27 10:20:45
I have an imageview that has its height and width set to fill_parent with a linearlayout that has the same values set. So I suppose this should set my images to fit the screen. But it only fits like 80% (margin top and bottom in landscape mode). I've tried the following code without success: Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); imgView.setMinimumWidth(width); imgView.setMinimumHeight(height); imgView.setMaxWidth(width); imgView.setMaxHeight(height); Any other ideas? use imgview.setScaleType(ScaleType.FIT_XY)

Android ImageView size not scaling with source image

混江龙づ霸主 提交于 2019-11-27 10:19:23
I have a few ImageViews inside a LinearLayout. I need to scale down the ImageViews so that they maintain their aspect ratios whilst fitting inside the LinearLayout vertically. Horizontally, I just need them to be adjacent to each other. I've made a simplified test bed for this which nests weighted Layouts so that I have a wide, but not very tall, LinearLayout for the ImageViews - <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">

Unwanted padding around an ImageView

时光毁灭记忆、已成空白 提交于 2019-11-27 10:12:59
I need to include a header graphic in all of my activities/views. The file with the header is called header.xml: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#0000FF" android:padding="0dip"> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/header" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0dip" android:layout_marginTop="0dip" android:layout

Android: java.lang.ClassCastException: android.widget.imageView cannot be cast to android.widget.textView

六眼飞鱼酱① 提交于 2019-11-27 09:44:12
问题 I can't fix this problem on my listview template: i have the error as in the title of my post, but i won't cast imageview to textview. Here's my code: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="200dip" android:layout_weight="1" android:paddingBottom="10dip" > <TextView android:id="@+id/mq" android:layout_width="wrap_content" android:layout_height="wrap_content"

Resizing images to fit the parent node

半腔热情 提交于 2019-11-27 09:01:01
How do I get an image in an ImageView to automatically resize such that it always fits the parent node? Here is a small code example: @Override public void start(Stage stage) throws Exception { BorderPane pane = new BorderPane(); ImageView img = new ImageView("http://..."); //didn't work for me: //img.fitWidthProperty().bind(new SimpleDoubleProperty(stage.getWidth())); pane.setCenter(img); Scene scene = new Scene(pane); stage.setScene(scene); stage.show(); } @Override public void start(Stage stage) throws Exception { BorderPane pane = new BorderPane(); ImageView img = new ImageView("http://...

Images in iOS push notification

与世无争的帅哥 提交于 2019-11-27 08:58:59
问题 I am trying to send images in push notifications I have made the notifications registrations in app delegate and apns device token is generating properly. ALso I have coded in service ext as follows: import UserNotifications class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent? override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping

Set ImageView's max width as a percent of its parent's width

非 Y 不嫁゛ 提交于 2019-11-27 08:53:44
I'm loading navigation from a website, where each item has a title, description, and image. I want to have all of the titles and descriptions centered along the same axis. I'm using the following layout for each item in a ListView. It works fine when the images are half as wide as they are tall, but not if they are any wider - the text goes under the image. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="horizontal"> <LinearLayout android

how to compress image for imageview in android

拟墨画扇 提交于 2019-11-27 08:43:08
问题 Hi I want to show 3 or 4 image in my view that are stored in sdcard the size of images is 1-2 MB approximately. My problem is when I use image in imageview then it throw out of memory exception i have create bit and pass option when decoding image to bitmap 02-26 13:16:54.946: ERROR/dalvikvm-heap(23410): 15980544-byte external allocation too large for this process. 02-26 13:16:54.946: ERROR/dalvikvm(23410): Out of memory: Heap Size=3407KB, Allocated=2801KB, Bitmap Size=15630KB, Limit=21884KB

Get Image from the Gallery and Show in ImageView

删除回忆录丶 提交于 2019-11-27 08:37:09
I need to get an image from the gallery on a button click and show it into the imageview. I am doing it in the following way: btn_image_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getImageFromAlbum(); } }); The method Definition is as: private void getImageFromAlbum(){ try{ Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, RESULT_LOAD_IMAGE); }catch(Exception exp){ Log.i("Error",exp.toString()); } } The activity result method is @Override protected void

Android:Issue Image resolution

穿精又带淫゛_ 提交于 2019-11-27 08:32:55
问题 Problem occurs while using high resolution image in device. imageview a; InputStream ims = getAssets().open("sam.png");//sam.png=520*1400 device=320*480 or 480*800 Drawable d=Drawable.createFromStream(ims, null); a.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); a.setImageDrawable(d); by using above code image leaves spaces on top and bottom to next contents or If I shrink an image by giving fixed px, its get blur image on its size. Anyway to solve this