imageview

Resize image to full width and fixed height with Picasso

混江龙づ霸主 提交于 2019-12-17 05:37:52
问题 I have a vertical LinearLayout where one of the items is an ImageView loaded using Picasso. I need to rise the image's width to the full device width, and to display the center part of the image cropped by a fixed height (150dp). I currently have the following code: Picasso.with(getActivity()) .load(imageUrl) .placeholder(R.drawable.placeholder) .error(R.drawable.error) .resize(screenWidth, imageHeight) .centerInside() .into(imageView); Which values should I put into screenWidth and

Android fade in and fade out with ImageView

与世无争的帅哥 提交于 2019-12-17 03:24:12
问题 I'm having some troubles with a slideshow I'm building. I've created 2 animations in xml for fade in and fade out: fadein.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="2000"/> </set> fadeout.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android">

Displaying emoticons in Android

亡梦爱人 提交于 2019-12-17 02:54:06
问题 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

ImageView be a square with dynamic width?

本小妞迷上赌 提交于 2019-12-17 02:44:10
问题 I have a GridView with ImageViews inside. I have 3 of them for each row. I can set correctly the width with WRAP_CONTENT and scaleType = CENTER_CROP, but I don't know how to set the ImageView's size to be a square. Here's what I did until now, it seems to be ok except the height, that is "static": imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT, 300)); I'm doing

How to set margin of ImageView using code, not xml

会有一股神秘感。 提交于 2019-12-17 02:07:11
问题 I want to add an unknown number of ImageView views to my layout with margin. In XML, I can use layout_margin like this: <ImageView android:layout_margin="5dip" android:src="@drawable/image" /> There is ImageView.setPadding() , but no ImageView.setMargin() . I think it's along the lines of ImageView.setLayoutParams(LayoutParams) , but not sure what to feed into that. Does anyone know? 回答1: android.view.ViewGroup.MarginLayoutParams has a method setMargins(left, top, right, bottom) . Direct

Grid of images inside ScrollView

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 01:38:38
问题 I'm trying to create a screen with both text and images. I want the images to be laid out like a grid, as shown below, but I want them to have no scroll functionality other that the one provided by the surrounding ScrollView. An image will best illustrate my question: <ScrollView> <LinearLayout> <ImageView /> <TextView /> <GridView /> <TextView /> </LinearLayout> </ScrollView> What is the best way to make show a grid of a varying number of images, where the grid does not have scroll

Grid of images inside ScrollView

那年仲夏 提交于 2019-12-17 01:36:28
问题 I'm trying to create a screen with both text and images. I want the images to be laid out like a grid, as shown below, but I want them to have no scroll functionality other that the one provided by the surrounding ScrollView. An image will best illustrate my question: <ScrollView> <LinearLayout> <ImageView /> <TextView /> <GridView /> <TextView /> </LinearLayout> </ScrollView> What is the best way to make show a grid of a varying number of images, where the grid does not have scroll

Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions?

本秂侑毒 提交于 2019-12-16 20:14:08
问题 How to fit an image of random size to an ImageView ? When: Initially ImageView dimensions are 250dp * 250dp The image's larger dimension should be scaled up/down to 250dp The image should keep its aspect ratio The ImageView dimensions should match scaled image's dimensions after scaling E.g. for an image of 100*150, the image and the ImageView should be 166*250. E.g. for an image of 150*100, the image and the ImageView should be 250*166. If I set the bounds as <ImageView android:id="@+id

ImageView in circular through xml

╄→гoц情女王★ 提交于 2019-12-16 20:05:45
问题 I'd Like to make any image from my ImageView to be circular with a border. I searched but couldn't find any useful information (anything that I tried didn't work). How can I achieve this through xml: Create an ImageView with certain src and make it circular with a border? 回答1: You can make a simple circle with white border and transparent content with shape. // res/drawable/circle.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadius="0dp" android:shape=

setText Textview from custum imageview

▼魔方 西西 提交于 2019-12-14 04:11:25
问题 I have an activity which has custom imageView. in imageView, I want to call a method from the activity, and that method wants setText Textview. is it possible? I have done these code but I've encountered an error. MainActivity: package com.example.helloworld; import android.os.Bundle; import android.app.Activity; import android.util.Log; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R