I am trying to display the accelerometer data in 3 rows like this:
X: 9.8 m/s2
Y: 0.0 m/s2
Z: -3.2 m/s2
But no matter what I have tried, I cannot seem to prevent the m/s2 from shifting back and forth when one of the values goes above 9.9 or negative.
E.g.
Before
X: 0.0 m/s2
After
X: -5.0 m/s2
I have tried tablelayout but the column just stretches, relativelayout, linearlayout and every possible padding combination I can think of.
Here’s a sample of my XML code which is inside of a vertical linear layout.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="X:"
android:textSize="30sp" />
<TextView
android:id="@+id/x_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="30sp"
android:paddingRight="30sp"
android:text=" "
android:textSize="30sp"/>
<TextView
android:id="@+id/xAccelUnits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textSize="30sp" />
</LinearLayout>
Thanks for your help!
you need to fix the size of the text view. It can be either a width in dp : layout_width=”30dp”
or you can use weights: layout_width=”0dp” layout_weight=”1″ for each TextView so that each takes a third of the screen (by modifying the weight and the weight_sum in the linear layout, you can give the width in fractions of the screen width)