Android Wrap_Content - java

When I add a button and set the Layout_Width, Layout_Height to Wrap_Content. What am I referring to because when I do that. Also, I see a box expand to fit the content. What is that box? I know that box is not the layout because my relative layout is set to fit parents. So what is the container that hold the button and allows me to modified the layout of that container?

Wrap_Content will take as much space as required by the element, it has setted height and width for.

wrap_content simply means that it'll wrap the content whatever may it be. In your case, the content would be the text in Button.
For example, if you have a button with text Click Me, then it'll take only the space required to fit the text Click me into the button box.
If you increase the text size, the button will automatically increase to fit the text in it.

Related

JavaFX Button does not scale with windows font size settings

The buttons in my JavaFX application look very nice on all operating systems with default font settings.
Howerver, if I increase the scale of text in the windows control panel,
the text on the JavaFX buttons increases wheareas the button size stays the same.
Therefore I get a button with 3 letters and an ellipsis (...).
How can I achieve that control elements in javaFX scale according to the system font?
It depends of multiple things.
First the layout in wich are your button.
And if you set a hard size to your button.
verify that you don't set a size to your button. And the parent layout size to a size smaller than the button size.
And try to set your button size with button.setPrefWidth(Control.USE_COMPUTED_SIZE) if it's still not working your parent layout is probably the cause.
You should try to play a little with SceneBuilder for a better understanding of how layout works

SWT button position after resizing

I'm working with SWT. I created a button, and it supposed to change its text after being pressed.
The second text is wider than the first one, and the button does not being re-sized appropriately.
so I used button.pack(), and setSize() functions. The real issue is actually with its alignment in the shell after this size changing.
it's being expanded to the right instead to the left.
I guess it's actually the normal behavior, but I'm not sure where to change it.
I tried to change things by creating a gridData but it only did worse.
The button parent is tabFolder, and the last consists of a gridlayout with two uneven columns, the spesific button is on the second column.
I tried to change things with the margins and few others, but without success.
currently all the configurations are default.
This is my button:
This is how I would like it to behave:
any help would be highly appreciated.
many thanks!
i would need some code to be sure, but it looks like you need to call tabFolder.layout(true) after changing the button text to compute the new position of your button

Eclipse android widget moving

I am designing my activity screen using eclipse but whenever I move an object e.g. a button it snaps around and I find it hard to position things where i want them.
Is there some setting I can change as as soon as I add a second button it snaps the other button to another position it is so annoying!
Also if I have an image button why can't i resize this, even with a normal button if i try to make it larger it just fits to the text and wont make the button bigger or it just flicks to a random place on the activity?
thanks
Probably you're trying to place components freely in the View but you're not considering the LayoutManager behavior. If you try to position your component in a LinearLayout, for example, the components will be placed following its rules, and these components will not stay where you drop them.
Try to understand better how the layouts works on Android. But for now, the AbsoluteLayout or RelativeLayout may be what you're looking for.
About the components size, you'll need to understand better how to use layout properties for these components. See the question How to size buttons for more information.

Scrollable vertical list of text box inputs using Java Swing

I'm trying to build a simple interface for an assignment, in which multi-line word-wrapped input boxes can be stacked vertically in a single, fixed-width column. then the whole stack (if tall enough) has to scroll vertically inside of a scroll pane with the same fixed width and a fixed height.
The active box has to change height dynamically to fit the amount of text as it is being typed/deleted. This means the y position of all subsequent inputs in the column should change accordingly. A layout manager's job, right?
I started reading about the swing layouts, and it seemed like only the GridBagLayout could do this. Since this is my app's only interface window, it seemed like a clunky layout to achieve something simple.
So, which swing layout should I use, along with which text input class for word-wrapping and auto height adjustment? Thanks.
A BoxLayout might be what you are after for this use-case.

How to adjust the height and bold the text of the tab's in android programmatically?

Can someone tell me how should i adjust the height of my three tabs's diagrammatically rather than in xml because my picture overlaps the wording therefore i had to adjust my tab's slightly longer but width still remain the same... And how should i bold the text string in the indicator at the same time? But how should i do that in my current context of code i'm rather in android..
You can use custom layout for your tabs here is an example source on how to do this
android-custom-tabs

Categories