Android Development #7

Make the text box size flexible and then run the app…

Divyendra Rajawat
2 min readMar 24, 2021
Photo by Daniel Romero on Unsplash

To create a layout that’s responsive to different screen sizes, you need to make the text box stretch to fill the horizontal space that remains after the button and margins are accounted for.

Before you continue, click (Select Design Surface) in the toolbar and select Blueprint.

To make the text box flexible, follow these steps:

  1. Select both views. To do so, click one, hold Shift, then click the other, and then right-click either one and select Chains > Create Horizontal Chain. The layout then appears.
  2. Select the button and open the Attributes window. Then, use the constraint Widget to set the right margin to 16 dp.
  3. Click the text box to view its attributes. Then, click the width indicator twice so it’s set to a jagged line (Match Constraint).

Now the layout is done.

If your layout didn’t turn out as expected, click See the final layout XML below to see what your XML should look like. Compare it to what you see in the Code tab. If your attributes appear in a different order that’s okay.

Run the app

If your app is already installed on the device, simple apply the changes and. Or, click Run ‘app’ to install and run the app.

That’s it for today guys…In the next blog we will be learning how to start another activity in the app…

--

--