question

njsokalski avatar image
0 Votes"
njsokalski asked RobCaplan edited

TextView Not Updating Width When Wrapping Inside GridLayout

I have a TextView and Button beside each other inside a GridLayout. I want the Button to use the minimum amount of space, and when the TextView wraps (if necessary), I want the width of the TextView to update so that the TextView & Button are always next to each other. I have tried using wrap_content & match_parent, as well as layout_columnWeight, but none of them seem to solve the problem. I also want the GridLayout containing the TextView & Button to be horizontally centered on the page. How can I get the TextView to automatically update the width (the width does not change, but it will obviously be different for different devices or if the orientation changes)? Thanks.

dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TextView and Button beside each other inside a GridLayout. I want the Button to use the minimum amount of space, and when the TextView wraps (if necessary), I want the width of the TextView to update so that the TextView & Button are always next to each other,I also want the GridLayout containing the TextView & Button to be horizontally centered on the page.

Do you want to TextView and Button in the same line, and Button's layout_width and layout_height are wrap_content, Textview's layout_width should be match_parent and layout_height will be wrap_content. And you want to TextView & Button to be horizontally centered on the page. Set the android:layout_gravity="center_horizontal" will meet the requirement, I get the following result.

110112-image.png


0 Votes 0 ·
image.png (80.1 KiB)

0 Answers