i wanted to create a custom dialog like the first image for a Android game.after a lot of trial and error i was able to create a dialog box that's looks like the 2nd screenshot image.
even though it looks identical to what i wanted to achieve,but it shows white pixels around the image even though it is a png.
How can i remove the white pixels from the screenshot dialog box image and make it look identical to the first image?
Add this code to ur dialog box to make it transparent
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
or
dialog.getWindow().setBackgroundDrawable(new ColorDrawableResource(R.color.transparent));
Related
I have been having a tuff few days with the EditTextPreference object. No matter which emulator I use this on, it seems to change color slightly but always makes my text the same color as the widget itself. (Yes, I know it's not really a widget).
I can change the TEXT color and the BACKGROUND TEXT color in the XML code, but this does not help because the "CANCEL" and "OK" confirmation buttons (which are part of the widget)to tap are yellow and impossible to see on the white widget background.
Is there any way in XML to make this widget a different color? This has been very frustrating.
You can set background colour of any widget by property
android:background="#ffff00"
enter any hex code at place of #ffff00
You can pick up hex code from here
you can also set a picture as a background of widget
android:background="#drawable/your_image"
place your_image in drawable folder
Is there a way to do both
button.setBackground(Color.green.darker());
and
button.setIcon(new ImageIcon(buttonImg.getScaledInstance(15, 15, Image.SCALE_SMOOTH)));
so that both the image and the background color are visible? Is there some sort of transparency setting on the button's image that I'm missing? Any help would be greatly appreciated.
EDIT:
Here is the image I'm trying to use. As you can see, it has transparency.
http://www.clipartlord.com/wp-content/uploads/2013/09/bomb3.png
What I am trying to get is the image to show up on the Button with the background color of green filling in the transparency. Right now when I try to do it, if I add the image at all, the background color is not visible whatsoever. But if I don't add the image, the background color is visible. I hope this helps.
Probably the LookAndFeel does not support what you want to achieve. Here is an image from the meta theme, on the left, and osx aqua theme.
If you want all of your JButton backgrounds to change you can try using a LookAndFeel that supports changing the UI. Unfortunately the aqua them does not let you change the default background for a button even using the UIManager#set
If you only want to do one button, you can change the button UI.
button.setUI(new BasicButtonUI());
That one doesn't look too nice, you can set the UI to one from another LookAndFeel,
button.setUI(new MotifButtonUI());
(Also doesn't look very nice, but now it buttons.)
Finally you can also create your own ButtonUI, or do some custom painting.
Hello I have some questions for adding images for a ImageButton.
I have an icon for example a play button now if I hover over the button it just should get a blue surounding box the inside Image should not change.
Should I draw for every icon the two states or are there other options.
If an button is not clickable it should get Grey. Same how to do this? Add an additional Image to every Icon?
For what is the Checked drawable in the ImageButton?
ImageButtons have a drawable for their background (up, down, over, etc.) and a drawable for the image on top of the button (imageUp, imageDown, imageOver, etc.). The only ones you must provide are up for the background and imageUp for the icon. These are the defaults used when you leave the other states null. But for visual reasons, you need down for the background or it will be hard to tell if the button is being pressed. It's up to you whether you think you need to also change the icon appearance with an imageDown.
All you need is to add the background drawable for disabled. If you want the icon to also turn gray, you need to create a gray version of the icon and assign it to imageDisabled.
The Buttons in Scene2d all support toggle functionality. When you press it, it will toggle to the checked state, so you can use the checked drawable to change its appearance while it is stuck down. If you don't want that to happen, leave the checked drawable null.
I followed this link http://www.androidbegin.com/tutorial/android-implementing-viewpager-into-gridview-tutorial/ to obtain gridview in viewpager. But my problem is that the image displayed as full screen in viewpager appear to be cut in gridview window. I want the image that appear as full screen should also appear in gridview window. In other words, the image displayed as full screen should appear as whole in small size image in gridview window.I meant something like the images displayed in this question link...Order of images in Grid View in Android
I just start with programming, so please give some explanations, or it will be great if you also give some codes :)
I suggest you have a look at ImageView.ScaleType. It it will show you how the image should be scaled, cropped, etc. to be displayed in an ImageView.
I have a custom popup window with a custom image background in which I need to place three custom buttons with their own background images. I have only one set of images for all the components, so I want all the parts to scale appropriately. My question now is how do I make sure that the buttons line up with the appropriate parts of the background image of the popup window. I have been experimenting with all sorts of widths and heights and I can not make it look consistent on all my test devices. Can anyone give me some pointers?
EDIT: Just to make it as clear as possible, the image below illustrates the kind of thing I am talking about:
I want the graphical button to line up with the arrows which are a part of the popup window background image.
arrange buttons in an xml layout and set this view to your custom popup and you can set images to buttons from code.