ImageView doesn't appear - android

I have dragged an ImageView to layout and I selected the picture. But when I execute the application, It doesn't appear. What can I do to solve this ?
ImageView XML code;
<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
app:srcCompat="#mipmap/idlepoor_moneys"
android:id="#+id/imageView4"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

Add this property in Your image View
android:src="#mipmap/idlepoor_moneys"
Remove the following line from your code
app:srcCompat="#mipmap/idlepoor_moneys"

As allready said change
app:srcCompat="#mipmap/idlepoor_moneys"
to
android:src="#mipmap/idlepoor_moneys"
Also I recommend to put your images in the #drawable folder. The mipmap is where app icons are stored when making an app.
app:src="#drawable/idlepoor_moneys"
You can easily find the drawable from your project map. If you can't find it you can always right click the folder to get the path to it.

Related

How to compare a drawable inside an imageView with another drawable?

I have a drawable inside an imageView and I need to know which drawable is to modify it.
<ImageView
android:id="#+id/dice_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/empty_dice"
tools:src="#drawable/dice_1"/>
I already tried with constant state but it's deprecated and works sometimes
I found a solution. I put a tag inside each imageview to be able to track what image was inside. Every time I changed the image I updated the tag number.

How to add missing xml attribute to specific view in android studio automatically

I want to add specific XML attribute for the view in android layout file.
I am getting lint message to add contentDescription to ImageView for more 400 ImageView and I don't want to add it manually by going to each ImageView XML tag. so is there any way to automatically add missing attribute with its value in android studio.
Right click the layout folder, click Replace in Path. Then in string to match put in
<ImageView
then in string to replace field, put
<ImageView android:contentDescription="yourText"
Then, press Find. Finally press All Files.
Moxdroid:
And finally Reformat and Rearrange the code.
Me:
You don't need to reformat. Your ImageView output will look like this
<ImageView android:contentDescription="yourText"
android:id="#+id/img_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:background="#drawable/back_selector" />
Unless OCD kicks in, this is totally fine i guess.

MvvmCross binding image file to Android ImageView

I am trying to bind an image file to an Android ImageView that is within an MvxListView. The images are just not appearing when the View is shown.
I have included the MvvmCross.HotTuna.Plugin.File package.
ListVideo.axml (snippet)
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/holo_blue_bright"
local:MvxBind="ImageUrl Thumbnail" />
The typical value for Thumbnail is
VideoData/2015-07-24-09-26-16/2fea9249-9370-4542-927a-c856e678f7b1.jpg
The value of Context.FilesDir.Path is /data/data/com.app.AppName/files
The image file /data/data/com.app.AppName/files/VideoData/2015-07-24-09-26-16/2fea9249-9370-4542-927a-c856e678f7b1.jpg does exist
I understand that to bind an image some custom folder determined within your app, I need to provide a path relative to Context.FilesDir.Path in order for the plugin to load it. I believe that the string in Thumbnail is correct.
But nothing is displayed in the ImageView. I have been banging my head against this one all morning. Any suggestions?
Edit :
I have managed to solve the problem !!
I needed the MvvmCross.HotTuna.Plugin.DownloadCache as well as the MvvmCross.HotTuna.Plugin.File package.
I have managed to solve the problem !!
I needed the MvvmCross.HotTuna.Plugin.DownloadCache as well as the MvvmCross.HotTuna.Plugin.File package.

How do I insert an image in an activity with android studio?

I am very new to android development, and have only read and completed the first guide in the android development site. The problem I have been having is that I can not put a picture in an activity. I have the picture in my drawables folder. I just don't know how to get it on the screen. Any help is appreciated.
since you followed the tutorial, I presume you have a screen that says Hello World.
that means you have some code in your layout xml that looks like this
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
you want to display an image, so instead of TextView you want to have ImageView. and instead of a text attribute you want an src attribute, that links to your drawable resource
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cool_pic"
/>
I'll Explain how to add an image using Android studio(2.3.3). First you need to add the image into res/drawable folder in the project. Like below
Now in go to activity_main.xml (or any activity you need to add image) and select the Design view. There you can see your Palette tool box on left side. You need to drag and drop ImageView.
It will prompt you Resources dialog box. In there select Drawable under the project section you can see your image. Like below
Select the image you want press Ok you can see the image on the Design view. If you want it configure using xml it would look like below.
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/homepage"
tools:layout_editor_absoluteX="55dp"
tools:layout_editor_absoluteY="130dp" />
You need to give image location using
app:srcCompat="#drawable/imagename"
When you have image into yours drawable gallery then you just need to pick the option of image view pick and drag into app activity you want to show and select the required image.
copy the image that you want to show in android app and paste in drawable folder. given below code
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/image"
/>

How do I include an image in an Android interface?

I am creating my first Android interface and I want to include a logo on. The logo is called logo.jpg. How do I do this?
Put logo.jpg into the res/drawable directory. Or if you have different size logos, put them in res/drawable-mdpi, res/drawable-hdpi, etc. See Providing Resources for detailed information.
To display the image, use ImageView. The XML refers to the image like this:
android:src="#drawable/logo"
you can add your logo( name logo.png for example) to the folder drawable , and then , add an imageView on your layout xml like this :
<ImageView
android:id="#+id/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/logo" <!-- this is the drawable source of your imageView -->
/>
Then place an image view where you would like the logo to be and set the image resource to R.drawable.logo or what ever the resource name is.

Categories

Resources