Best way to put vectorized symbols on button? Wingdings button title - android

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

Related

Images in drawable-v24 resource folder not showing up in image button?

I have various icons I am trying to use for some buttons. These icons exist in a drawable-v24 resource folder. When I try to set the "android:src="drawable-icon" to my resource, the image never shows up. Does it make a difference that the icon exists in "drawable-v24", but my resource calls the "drawable" folder? I'm sorry, I'm really not sure what to ask here. I'm very novice when it comes to this.
My XML code:
<ImageButton
android:id="#+id/history_button"
android:layout_width="74dp"
android:layout_height="81dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="#+id/horizontal_border"
app:layout_constraintEnd_toStartOf="#+id/vertical_border"
android:src="#drawable/icons8-time-machine-24" />
The button shows up as a plain gray button, without the black "time-machine" icon that should be showing up.
The compiler is having issues due to the naming of your drawable file namely the fact that you are using dashes instead of the "_" underscore sign usually employed. you can just name the drawable time_machine. let me know if this is the case.
look at this answer for reference: related question

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 to set background image for button in Android?

I Imported one image inside the drawable-mdpi, then implemented the image from button, but an error occurs no resource found here. How do I fix this issue?
I tried this:
main.xml
<Button
android:id="#+id/imageButtonSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable-mdpi/button_focused_orange"/>
All drawables are compiled under a single resource name, i.e. drawable. Android automatically chooses from which folder to take the drawable depending on the screen size, and hence you do not need to specifically point it out. Also, hard coding Android to use resources from a particular folder kind of defeats the purpose of having multiple folders for Android to choose from. To solve this issue, simply change:
android:background="#drawable-mdbi/button_focused_orange"/>
To
android:background="#drawable/button_focused_orange"/>
Should be #drawable/button_focused_orange
Not #drawable-mdpi/button_focused_orange
Try to clean and rebuild your project.
If you are usuing Eclipse you can do this by clicking project -> clean and then project -> Build project
You don't have to mention -mdpi to add background images, simply use drawable only. Here is you revised code. Try this.
<Button
android:id="#+id/imageButtonSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/button_focused_orange"/>

ImageButton with external image?

I'm searching a way to put my own image as an ImageButton. There is the src thing but it accepts only icons i thing. Any help?
This is pretty fundamental stuff which would be covered if you ran through tutorials.
There's more to it, but the general common procedure would be to include any images you want to use in your res/drawable folder for the project. Then, you'd usually reference the image in XML something like this:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/myimage" />

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