I can't see buttons in MaterialButtonToggleGroup - android

I want to use the toggle button group to make it look like the picture below.
enter image description here
However, if I insert a button into the toggleButton Group, the size of the button becomes very small. Even if the absolute size is given to each layout, only the size of the toggle Button Group is enlarged and the button inside is small, so I can't see it. When you take out the button, it returns to its normal size and you can see it well, but it looks small only in the group.
Can I know the reasons about this?

I am guessing that there must be separate styles in the toggleButton Group itself for buttons. Maybe you wanna check that.
Another reason I'm thinking is that maybe you have the width of the button set with % percentage, or with vh/vw(view height/width). If so button will change its size relative to the parent element size.

Related

Want to place multiple hidden buttons over a background image?

Not able to set hidden buttons over the background image, want to place hidden buttons exactly over the words (i.e total 5 hidden buttons over background image). Help!.
Try to use AbsoluteLayout or RelativeLayout with button alpha 0%.
Also consider doing it in another way. It may go wrong on different screen sizes and orienantions.
You should try to use RelativeLayout to do this (if you want to create a custom view, eg in corners). RelativeLayout is a Layout where the positions of the children can be described in relation to each other or to the parent.
See this link: RelativeLayout
See the example here and information from here

Android: Text container width inside a button

I try to do a custom keyboard, so I have a small buttons and the text doesn't fit in my buttons, but it have a few pixels for it:
Can I increase text container width inside my buttons?
You can try:
set button Paddings to zero:
button.setPadding(0,0,0,0);
(I dont really know how custom keyboards work but you may try using TextViews instead of Buttons, and you can set your Image or Background to your TextView aswell. Can use pressed states with selectors and etc...)
Or you can make your own class, and #Override their onDraw method to draw your own text(or charachter) for your view.
As far as i know there are no specific methods to increase text container.
You may consider using ImageButton instead of an ordinary Button as keyboard buttons. As you will have the freedom to edit the image the way you want to.

Highlight a Imagebutton to show notifications

I have an application in which you can accept friend request. For this purpose i have kept an activity which will start when an image button is pressed.
When my application starts i want to check if the user has any requests and if yes the button should be highlighted.
How do i do this?
Take another highlighted colour image. and Set TextView on that image.
Ex: RelativeLayout for that RelativeLayout background is your highlighted colour image then set TextView on that RelativeLayout.
Based on your condition put this image and number of pendings to TextView
you could make two imagebuttons. One which is in your normal colour and one in the highlighted colour, which are on the same place.
Depending on the situation you make either the one or the other (in-)visible.

visibility of buttons and layout

I have 10*3 buttons on my screen. When I click a button, I want it to be unvisible, so I do :
arg0.setVisibility(View.GONE);
But whenever the button is gone, the buttons change their size.
For example, if at the begining every button took 1/3 of a row, now when a button is gone the other buttons in the row get wider..
Is there a way to make them not change their size when a button is removed?
Use View.INVISIBLE. Using GONE makes it as if it wasn't there (so it no longer takes up space). Invisible just makes it disappear.

How to set the size of spinner

I want to know how to set the size of spinner.When i added large values to spinner list,the spinner expands and as result it pushes the labelField to the further left.
I want to know the how to set the spinner size to be a constant one
Presumably, you presently have the Spinner set with android:layout_width="wrap_content". That will expand as the values expand. If that is not what you want, do something else. RelativeLayout is particularly useful here, as you can anchor both the left and right sides of the Spinners to things they should not expand past (e.g., left to another widget, right to the right edge of the screen).
Just in case anyone come to this page again... One may refer to here:
How to change spinner text size and text color?

Categories

Resources