imageview

Center ImageView inside another ImageView in Android

不想你离开。 提交于 2020-01-01 06:39:09
问题 Well I have to fit one ImageView inside another one. It is smaller and has to be exactly at the center. I have both images scaled for different screen resolutions but I can test only on one phone and I am wondering if I set the second image's height and width with dpi to fit my screen resolution will it be perfectly matched on all screens or is there any property in Android aside from setting the height and width that will automatically center one ImageView inside of other ImageView? Edit: It

ImageView: automatically recycle bitmap if ImageView is not visible (within ScrollView)

房东的猫 提交于 2020-01-01 04:57:08
问题 So, I've been looking at the ImageView source for a while, but I haven't figured out a hook to do this yet. The problem: having, let's say, 30 400x800 images inside a ScrollView (the number of images is variable). Since they fit exactly in the screen they will take 1.3 MB of RAM each. What I want: to be able to load/unload bitmaps for the ImageViews that are currently visible inside a ScrollView. If the user scrolls and the bitmap is no longer visible (within a distance threshold) the bitmap

Only the original thread that created a view hierarchy can touch its views

牧云@^-^@ 提交于 2020-01-01 02:38:09
问题 I'm trying to get an ImageView to animate between 2 images in my drawable folder. I thought everything would work fine, but the log is showing an error: Only the original thread that created a view hierarchy can touch its views. Heres my code: public class ExerciseActivity extends Activity { private ExercisesDataSource datasource; private Cursor cursor; private ImageView image_1_view; private Timer _timer; private int _index; @Override public void onCreate(Bundle savedInstanceState) { super

How to Set BackgroundColor on ImageView on Android?

不打扰是莪最后的温柔 提交于 2020-01-01 01:11:26
问题 I tried a couple things and nothing is working... I'm trying to change the BackgroundColor on a ImageView on Android, but nothing happens... Here is my xml: <ImageView android:id="@+id/imageView1" android:layout_width="350dp" android:layout_height="550dp" android:layout_above="@+id/btnInfo" android:layout_alignLeft="@+id/fundo" android:layout_alignRight="@+id/btnInfo" android:layout_alignTop="@+id/fundo" android:layout_centerHorizontal="true" android:contentDescription="@string/backgroundMain

Overlay over an ImageView on Android

旧街凉风 提交于 2019-12-31 10:39:57
问题 So I have a list of images that come from the web, I don't know which color are they and I want to place a text over the ImageView. My idea is to place the ImageView, an image overlay with transparency gradient over that ImageView and the text above it. I want to mimic this behaviour: Is there anyway to do this via XML? 回答1: When you write the XML for your list items which get inflated in the getView(...) of whatever ListAdapter you've written you can surely do this. Something like this for

Get android's id resource from a string

人走茶凉 提交于 2019-12-31 04:48:47
问题 In my Kotlin app I have some ImageViews (in activity_main.xml ): imageView_0 , imageView_1 , imageView_2 and imageView_3 . How can I access the view in a loop from 0 to 3? This won't work: val imageView: ImageView = findViewById<ImageView>("R.id.imageView_" + index) as ImageView 回答1: for(i in 1..3){ val id: int=getResources().getIdentifier("imageview_"+i, "id", getPackageName()) imageview[i]=findViewById(id) as ImageView } If you have in the xml , imageview_1 , imageview_2 , imageview_3 回答2:

Putting ImageView Over ImageView in Layout [closed]

我是研究僧i 提交于 2019-12-31 03:12:21
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I have created an Android Application in that I want to put ImageView over ImageView. How to make i possible. Thanks. 回答1: I have created code for you: See this is XML code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas

ImageView bitmap scale dimensions

十年热恋 提交于 2019-12-31 02:58:11
问题 I have a Bitmap that is larger than the ImageView that I'm putting it in. I have the ScaleType set to center_inside. How do I get the dimensions of the scaled down image? 回答1: Ok. I probably should have been clearer. I needed the height and width of the scaled Bitmap before it's ever drawn to the screen so that I could draw some overlays in the correct position. I knew the position of the overlays in the original Bitmap but not the scaled. I figured out some simple formulas to calculate where

How to apply half circle mask to an ImageView

妖精的绣舞 提交于 2019-12-30 07:15:14
问题 I have an image, a half circle frame image and I need to put that image inside this frame. But I need to apply mask to my image so it is only displayed inside frame. For example this is my image: And my desired result should be like that: The red frame also an image view which inside is transparent. How can I achieve this in Android? 回答1: There's a great tutorial on Styling Android blog in four parts that explains how you can achieve this. Edit: I've edited the code in part two of the

How to apply half circle mask to an ImageView

北战南征 提交于 2019-12-30 07:15:07
问题 I have an image, a half circle frame image and I need to put that image inside this frame. But I need to apply mask to my image so it is only displayed inside frame. For example this is my image: And my desired result should be like that: The red frame also an image view which inside is transparent. How can I achieve this in Android? 回答1: There's a great tutorial on Styling Android blog in four parts that explains how you can achieve this. Edit: I've edited the code in part two of the