Android: Text container width inside a button - android

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.

Related

I can't see buttons in MaterialButtonToggleGroup

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.

Need recommendations for overlay views or layouts in Android

In an Android app I have a background image and two buttons on it.
This is a partial screenshot:
I ask you for the best approach to click on the sinopsis button to show an overlay text, like this:
and also to click the fotos button to show an image slider, like this:
I don't want you to show me any code. I only need recommendations to know what kind of layouts or overlay views I should use to obtain the shown behaviours.
Thank you.
A simple TextView is enough. A TextView can have a background, translucent as in your case, or gradients, etc., and padding. You can fill it with Spanned Text so you could use hyperlinks, bold, colors, etc.. If you need scrolling, TextView also supports scrolling out of the box, but it'd be better to put it inside a ScrollView because the scroll will be smoother. In any case you don't need additional layouts.
You can just use a container layout (like LinearLayout. RelativeLayout, ScrollView, etc.. depending on what you want) and specify that to have a background image and then specify your drawable. You can then use TextView to display text. Don't forget though that you will have to create custom TextViews to achieve your design.
TextView can have transparent background and so, you can get the overlay effect.

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

Custom buttons arangement in Android

I'm trying to build an Android app where I would like to display some Buttons in various places, as in the demo image attached.
The challenge here is creating the custom buttons and arranging them.
As for the custom Buttons, I guess I could achieve that using CustomViews or a simple button with a Custom Drawable as Background.
Are these the right points to start, any other ideas?
On arranging them, I have no clue how to achieve that.
As Android_Crazy and Closeratio have already said, a RelativeLayout is the most suitable option for custom placement of buttons in general. However, for the exact placement of buttons pictured in your example, a LinearLayout would work just fine.
In a LinearLayout you may place views under or above eachother (with android:orientation = "vertical", relevant for your example) or next to each other (android:orientation = "horizontal"). You can also add margin to your views to alter the horizontal position (layout_marginLeft or layout_marginRight) or the vertical position (layout_marginTop or layout_marginBottom).
As for the buttons' appearance, I always use custom background drawables, usually with a custom xml to add a different drawable for when the button is being pressed or selected.

Only show the arrowbutton of a spinner

I would like to use a spinner but only show the arrow on the right side like Android does in it's settings menu. (like for example by Screen timeout)
I can set the width to +/- 65px but then I've only got rounded corners on the rightside and not the left.
Thnx for your help!
Patrick
Are you sure they use a spinner?
You could achieve the same thing by simply placing a round button to the right-hand side and when pressed it triggers a popup ListView. The drawable for that button is...
"#drawable/ic_btn_round_more_normal"
If you are just trying to get it the dropdown to be all the way to the right rather than narrower, you can simply set the tag on the spinner in the xml to use android:layout_width="fill_parent". If you want to just have the button without the border, the Android Preferences have their own layout objects. I have just asked at elsewhere how to get those elements in a non-preferances view: Howto make a layout similar to the ones in settings.
What I did is the following:
Set the layout_width of the Spinner to 48dp and in code set an adapter which serves views with a size of 0dp x 0dp. The dropdown view is a normal (visible) view.

Categories

Resources