I'm having a problem calling a picture to view. In my app after they click the button i want to take them to a new page where it will display a picture and under it some text. For this example say i want a pic if dog to be at the top of the page then under it say i want something like the breed and the cost of breed. Can anyone help me?
Use this XML for your page what will display the image:
<ImageView
android:id="#+id/image"
android:src="src"
/>
<TextView
android:text="image text"
android:layout_below ="#id/image"
/>
Of course, add more options to the views
Some good references:
http://developer.android.com/reference/android/widget/ImageView.html
http://developer.android.com/reference/android/widget/TextView.html
http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html
Use ImageView.
Also for other questions like this, I highly recommend reading the User Interface section of the online Android Developer's Guide.
In a layout XML, put a LinearLayout, oriented vertically, containing first an ImageView widget then a TextView widget. You can set the text using TextView#setText(String) and the image using ImageView#setDrawable(...).
This layout will be used by an activity that reads the Extra information (for example the text to show and the image URL or the image path on the SDCard) when it starts.
You should read more about Views on the Android developer's guide as advised by Shawn Lauzon.
write the above code in your .xml
<ImageView android:id="#+id/img"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center">
</ImageView>
and add this line in your .java class
img = (ImageView) findViewById(R.id.img);
Related
I'm currently trying to build a Note making app and one of its feature is supposed to be Opening the camera,taking an image and I should display this image on the EditText along with other Text which is already present in the EditText.
I know how to Open the camera,saving the image and stuff but How do you add the Image I captured below/above an EditText?
I believe that we need ImageView to display images but how do I incorporate this in my app along with the EditText?
Something like this...
Kindly point me to anything which helps me in finding how to do it since I'm unable to find anything useful.
<LinearLayout orientaion:vertical >
<EditText>
</EditText>
<ImageView>
</ImageView>
</LinearLayout>
If you want many ImageViews,You can create many at run time while taking photo.
ImageView view = new ImageView(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Linear_layout.addView(view, lp);
You should be able to add an image directly into the editText by using html tags to do so. I'm not entirely sure on how to acquire uri reference to the image, but i assume thats not too hard.
Wrap the EditText in a LinearLayout, then add the ImageView to that LinearLayout.
If you define it in xml, it should look like this:
<LinearLayout ...>
<EditText .../>
<ImageView .../>
</LinearLayout>
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"
/>
Is it possible to set an image, for a custom "View" or "Control" to be shown in Eclipse? So that it somehow loads the image of the View so it can be previewed before adding it? Say for an open Library of Views, this would be ideal and good. I have no clue where to start looking.
To clarify, when going under "Form Widgets" there are preview of the controls like Buttons, TextView, RatingBar for example. Only this functionality for a control. I'm not sure if it's Eclipse specific, but...
Any ideas?
Yes you can use ImageView try below code in xml file:
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/icon" />
Yes, It is possible.
Here my CustomView (which extends ImageView)
First of all, can I just say, I find laying out android UI's to be a frustrating experience? I used to think the XML layouts were simple and clean and awesome but every time I try to make anything with it I spend hours trying to do the simplest things!
In this particular instance I'm trying to make a simple horizontal bar that contains an image button of fixed size on the right and to the left of it I want an ImageView that takes up the rest of the available width. I see similar constructs all the time in the UI: the search box that appears at the top of the screen when searching, the text area and send button for composing text/googletalk messages, etc.
I've tried both a horizontal linear layout and a relative layout, and I can't get the button to look right in either one. My latest attempt has the following layout code:
It looks like this:
Using the hiearchyviewer indicates that both the imageview and the button have the same height (45px). And it shows the view dimensions and positions to be exactly what I'm looking for. Same height (differing widths of course since the ImageView is much wider). And they butt right up next to each other, centered in the Relative Layout. However the button as drawn on screen is obviously not taking up the full ImageButton view. I'm thinking it's something weird about the android system 9patch drawable used for the ImageButton background. But what do I know? I can't get it to look right no matter what I try.
How did you set up your RelativeLayout? Try to set it up like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageButton android:layout_width="wrap_content" android:src="#drawable/icon" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:id="#+id/imgButton"></ImageButton>
<ImageView android:id="#+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:src="#drawable/red_button" android:scaleType="fitXY" android:layout_alignBottom="#+id/imgButton" android:layout_alignTop="#+id/imgButton" android:layout_toLeftOf="#+id/imgButton"></ImageView>
</RelativeLayout>
Hope this helps.
If dimensions are exactly how you are looking for , then in ImageButton and ImageView , use android:scaleType="fitXY" and check.
For simple case , I might use linearlayout with horizontal orientation with two buttons in it with proper weights.