Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Text (numeric) justification

$
0
0

I have a TextView field wherein the user is able to add digits to. As the digits are added to a string, to display in the field (ValText field, in the layout, below) I would like the string to retain it's position on the right, with respect to the screen, such that the string, though appended to, expands to the left, much as you would see with the display of a calculator, e.g.:

1

12 123 123. 123.4

Whereas right now, this exhibits behavior like:

1 12 123 123. 123.4

I have the layout for this specified below. Each time the string is appended to, I am simply:

TextView valText = (TextView)dialog.FindViewById(Resource.Id.ValText); valText.Text += s; //where s is the latest numeric character appended to the string.

How can I specify my layout, below, so as to display this as a calculator, the way I am trying to mimic?

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TableRow
        android:background="#ffffff00">
        <TextView
            android:id="@+id/DimText"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:background="#aaffff00"
            android:textColor="#ff000000"
            android:layout_gravity="left"
            android:layout_marginLeft="20dp" />
        <TextView
            android:id="@+id/ValText"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:background="#aaffff00"
            android:textColor="#ff000000"
            android:layout_gravity="right" />
        <TextView
            android:id="@+id/UnitsText"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#aaffff00"
            android:textColor="#ff000000"
            android:layout_gravity="center" />
    </TableRow>

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>