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.
Related
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.
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 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"
/>
Suppose I want to draw simple icon on the button surface. Let it be the cross or some letter.
What is the best way to do this? Can I use wingdings or webdings font on button?
As Android uses Unicode (utf-8) you can use any sign defined there, as long your font supports that. Just use copy and paste. The better solutions i think is using ImageButton using images from your drawables folder. This folder can be found in project/res/drawables or via Ecplipse Package-Explorer and you should use this to copy and paste your files in place (png, gif and jpg are supported)
In XML layout file a image is assigned the following way to an ImageButton
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
See also:
http://developer.android.com/reference/android/widget/ImageButton.html
http://developer.android.com/guide/topics/resources/providing-resources.html
http://developer.android.com/training/multiscreen/screendensities.html
can anybody tell how to display background image in a TextView in android?
If you are working with xmls you can add it as Praveen Chandrasekaran said doing:
android:background="#drawable/myResouce"
Before that you have to put your image file inside the res/drawable folder.
You can also change it from the code doing:
mTextView.setBackgroundResource(R.drawable.myResouce);
add a android:background="#drawable/imagefile" attribute on your TextView tag. Before that you have to put your image file inside the res/drawable folder.
android:background="#drawable/mark"
Also review.... your background image should be a 9.png and add some paddings for your content
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:layout_height="400dp" android:background="#drawable/mark"
android:paddingTop="5dp" android:paddingBottom="5dp" android:paddingLeft=