I have...
PNG file for Background
PNG file for Icon (drawableTop)
Text I want to put underneath this Button
It's similar to a Menu Icon. How to do that? I only found following ways. Both of them arent very nice:
Make two Buttons, one for Text one for the Picture
The Background PNG File needs a transparent area at the bottom in the size of the text.
After some months of working with Android it's not that hard anymore. You can set any View (ImageView, TextView, LinearLayout, RelativeLayout...) clickable.
So in this case I would go with a Relative- or LinearLayout. They also can use the same style, so the position of the icons are always the same.
Set the text as the button text via the attribute android:text. Use the android:drawableTop attribute to set an icon that will appear above the text.
Related
Is there an easy way to change the colour of the horizontal line that appears
when the TAB is active?
Usually it appears as Green... I use Edit Default Style to change the colour to blue/red when Text is active, but I could not find an equivalent for the Green Horizontal line?
(if can't see above Image, see
Is the Green an android / windows / Delphi default? I see some images with green shapes inside the Edit Default Style properties...
Can the Green horizontal line be changed to blue/red easily?
Can the Green horizontal line be disabled (set Invisible) easily without disabling the Active/non-active feature of the Tab text? I suppose I can set the Tab text to non-styled, and then manually change the colour of the Tab Text... but will be less elegant
Thanks for any input. I've checked the web for any link I can find (including How to change the color of active TAB in a TabControl, in Delphi)
The style used to paint the bottom line in the tabitems is TabItemStyle.Top.ActiveLink
You can use the style designer to change which rectangle is used for ActiveLink. For instance, you could click on this property to bring up the bitmaplinks editor, and then drag the rectangle so that the bottom line is not part of ActiveLink, and then your colored line is not drawn.
I'm new to Android development and I'm trying to implement some custom buttons, they should look something like this:
So I was wondering if I can use something like a imagebutton and use the image as a background and add text on top of it (I tried this but the text is always in the middle and doesn't have a label so its hard to see..), or should I write a custom style or theme for my button. In case that I have to write a custom style or theme, could you please help me out with this? How should I go about doing it?
For each of those Grid elements, create a framelayout for each, put the background and then the label in front. Frame layouts allow things on top of each other. You can put the labels with layout_gravity bottom and also add a transparent color to it so the image in the back can be seen. Also add a onClickListener to each of the framelayouts so they act as buttons.
I have start and end date time fields that look like in picture below. Blue color shows active selection - if we select right then blue color goes to right and white color appears on the left and vice versa.
Hardest part is to create that arrow style in the middle. What should i use because buttons are rectangles and I don't know how it could be done.
It's easy. Just use ninepatch.
You can start there:
http://radleymarx.com/blog/simple-guide-to-9-patch/
you need a custom image according to what you ask, maybe extend ToggleButton for that but basically what you want is the same component when pressing on two different places on the same component will dispatch different events.
I would for example extend Linear layout, make it vertical layout, put two clickable textView\buttons with 9 patch images as background ,like suggested before, one for the white part and the other for the blue part. and replace the background image for any event u like.
you can also create a StateListDrawable with actions for selected and deselected and set the state of each drawable upon the right click
In my android application, I use a listview and some linear layout on wich the user can click.
Of course, I had to set the background of my LinearLayout to a xml file where the stated pressed, selected are defined:
myView.setBackgroundDrawable(
getDrawable(android.R.drawable.list_selector_background));
So no problem I set the drawable to transparent when normal use and orange when clicked.
My only problem is that on the galaxy S and some other customized phone (Sense UI) the color of the listview clicked is blue or green!
So I need to pick this color to set it to the background of my linearlayout.
I don't want to mix orange and blue, or orange and green for my user!
Where can I get this color???
That woule be really helpfull!
Just found the answer:
android:background="#android:drawable/list_selector_background"
I would like to apply both an icon and text to a button. The button would have the icon centered in the button and text written at the bottom, centered. I could not get the text to center and be at the bottom using android:gravity.
A side note, for a layout with 6 buttons is a Table Layout the best way to do it? There is 3 rows and 2 columns. Thanks in advance.
Another side note, why does the button lose its rounded edges when I add background color?
You can use android:drawableTop attribute to set drawable on the top and text on the bottom.
You should also use stateful drawables.