Can you give some projects how to insert an image like that on android?I want to add that image in my xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
How can I display it my image?
Use an ImageView. It takes all the standard formats.
You can use an ImageView:
<ImageView
android:id="#+id/logo_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/logo" />
and place your image file into res/drawable/logo.gif (or in a resolution specific drawable directory)
If you want to display moving GIF then there is not direct aproach, You have to try a way around, Refer bellow link for more details.
REF GIF in Android
OR you can load the image in a web View and display it. ( web view should be able to display the animation )
Related
To run an example on android to use PinchZoom I found the following example. I was able to write a working example code which shows the View from the example - but it is all white! How can I use an actual image in this example?
I tried the following in the activity-xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<com.example.alexander.capycoding_pinchzoom.CanvasView
android:id="#+id/signature_canvas"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/image"
android:textColor="#FFFFFF" />
</FrameLayout>
to use an actual non-white image, but it does not work. (I also renamed the class from ZoomableImageView to CanvasView).
Maybe there is another/better example on how to make PinchZoom workable on a Canvas/Bitmap in android?
you are using a default image in the xml.use your image and by the way simply putting xml cannot alone perform the action.i suggest to use library files for the pinch zoom and then create a class for the zoom specification
I am not able to load the image. I tried the following
put the image in the drawable folder
then use the Image View tag
then able to load the picture for the app's icon, but not able to if I try to use picture inside my application.
what should I do to use a picture inside the created application
If you want to use an image from drawables you shold reference it from your layout via ImageView control:
<ImageView
android:id="#+id/this-is-your-image-view-id"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.00"
android:src="#drawable/this-is-your-drawable-name" />
I faced the same problem,fixed by using .png image,not other format .
I want to create a activity that looks like the gallery or whatsapp image view
I want the image to got displayed in its normal size and allow users to zoom in and out inside the ImageView so he can see the details of the image (which will contain text so i need to have zooming)
Please help cause i need this fast
This library provides zooming ImageViews.
Here is another great library i use.
https://github.com/sephiroth74/ImageViewZoom
Simply use this in xml instead of regular ImageView like this:
<your_package_name.ImageViewTouch
android:id="#+id/image_hq"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:contentDescription="#string/image_hq"
android:scaleType="matrix" />
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"
/>
I want to simply add a new header-style line in Settings top-level. Not an icon, like the other entries have to the left of the section text, but a screen-width image. This would be implemented elsewhere, but for now, I just want to be able to have an image be shown at all
This does not seem to be easily done, and I have not found a complete guide for something this simple anywhere.
For this I will need both the XML edits, AND the matching java counterpart.
Here is my current Java part:
setImageDrawable(R.id.logo);
And this is my XML side:
<ImageView
android:id="#+id/logo"
android:src="#drawable/romlogo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
My image is currently in /res/drawable-xhdpi/, and is named "romlogo.png" (461 x 113)
As it sits, it doesn't even compile. Not sure if I'm missing an import or what.
You have to parse a Drawable to the setImageDrawable(...) method. However, the XML code looks good. Do not set the image programmatically, it is already there stated in the property android:src="#drawable/romlogo". If you want to set it with code use something like this:
// fetch the imageview and afterwards set the drawable
// here consider the difference between R.id and R.drawable
ImageView iv = (ImageView) findViewById(R.id.logo);
iv.setImageDrawable(R.drawable.romlogo);
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#000"
android:gravity="center" >
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:paddingTop="0.1dp"
android:paddingLeft="0.1dp"
android:paddingRight="0,1dp"
android:scaleType="fitXY"
android:id="#+id/iv"
android:src="#drawable/organic"
android:layout_weight="30"/>
</RelativeLayout>
This will be the XML code for the appropriate output.Image as an header and of screen width