Skip to content
Advertisement

How to programmatically align two Textviews and a Seekbar in the same line?

How to programmatically align a textview, a seekbar and another textview in the same line in android studio?

Textview seekbar textview

I have written the following code snippet:

JavaScript

The following is my XML file:

JavaScript

Current scenario:

enter image description here

Advertisement

Answer

Currently the LinearLayout has android:orientation="vertical", so the Views appear one below the other.

If you want them to appear side by side, you should change the orientation to android:orientation="horizontal"

Or you can set the orientation programmatically:

JavaScript

Change the width to WRAP_CONTENT and set a weight so all three Views get a third of the available width:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement