imageview

android: stretch image in imageview to fit screen

旧时模样 提交于 2019-11-26 15:07:19
问题 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

Android ImageView size not scaling with source image

纵饮孤独 提交于 2019-11-26 15:07:12
问题 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"

Unwanted padding around an ImageView

ⅰ亾dé卋堺 提交于 2019-11-26 15:04:29
问题 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

Android: Scrolling an Imageview

与世无争的帅哥 提交于 2019-11-26 14:59:14
I have an ImageView that is twice the height of a normale screen ( 960 dip). I would like to scroll it nicely up and down on the screen. The bottom of the screen should contain a button. I have tried various combinations of ScrollView and Imageviews without any success. I have also thinkered with the :isScrollContainer attribute without results. Anyone knows how to do this? Cheers, Luca @cV2 Thank you so much for that code. It got me going in the direction I needed. Here's my modified version which stops scrolling at the edges of the image... // set maximum scroll amount (based on center of

Displaying emoticons in Android

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 14:54:04
My IM app has to support emoticons. They are GIFs and have textual representations, which are used in the input box if the user selects one of them. But I'd like to display them as images after they have been sent.Currently my custom array adapter displays the sent message in a TextView of a row. What is the proper method to display images dynamically based on the occurrence of their textual representation? Do I have to search for emoticon texts, and if one found, remove the TextView from the layout (relativeLayout fits most?) and add a TextView with the beginning of the IM, an ImageView with

Set ImageView&#39;s max width as a percent of its parent&#39;s width

醉酒当歌 提交于 2019-11-26 14:24:17
问题 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=

Setting Android images from string value

非 Y 不嫁゛ 提交于 2019-11-26 13:44:49
问题 Currently I'm drawing a PNG image in my Android application like so: ImageView image = new ImageView(context); image.setImageDrawable(context.getResources().getDrawable(R.drawable.testimage)) If I have a list of image names in a database, is there a way to set the drawable above using the image name? I already have the code to go through the database, I'm just looking to draw the image based on the value taken from here. For example, a record for the DB: ID: Name: ImageName: - Test testimage

How can I crop a bitmap for ImageView?

╄→гoц情女王★ 提交于 2019-11-26 12:42:55
问题 I know this should be simple , but android:scaleType=\"centerCrop\" doesn\'t crop Image I got image 1950 pixels wide and need it to be cropped by parent\'s width. But android:scaleType=\"centerCrop\" doesn\'t crop Image. What do I need to do in layout to show only first 400 pixels , for instance or whatever screen/parent width is Sorry for simple question - tried to Google it - only complicated questions there. And I\'m new, so don\'t downvote please) <RelativeLayout xmlns:android=\"http:/

Scale Image to fill ImageView width and keep aspect ratio

江枫思渺然 提交于 2019-11-26 12:39:31
I have a GridView . The data of GridView is request from a server. Here is the item layout in GridView : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/analysis_micon_bg" android:gravity="center_horizontal" android:orientation="vertical" android:paddingBottom="@dimen/half_activity_vertical_margin" android:paddingLeft="@dimen/half_activity_horizontal_margin" android:paddingRight="@dimen/half_activity_horizontal_margin" android:paddingTop="@dimen/half_activity_vertical

Android ImageView adjusting parent&#39;s height and fitting width

你离开我真会死。 提交于 2019-11-26 12:17:57
问题 Update : I solved this issue by using the method described in this answer I\'m a bit stuck with this issue, which I think should be pretty simple. So my app downloads an image, and renders the bitmap in an ImageView, a child element of a RelativeLayout. I would like the ImageView to fit the parent width, and to adapt it\'s size to keep the aspect ratio. Here is my XML : <?xml version=\"1.0\" encoding=\"utf-8\"?> <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"