1

Here is the text view:

<TextView
android:id="@+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:gravity="right"
android:textAlignment="viewEnd"
android:textColor="#ffffff"
android:textSize="50sp"/>

I'm using :

String inputStr = doubleToString(result);
input.setText(inputStr);

The TextView simply expands by more lines to fit large numbers (now string). I guess that's because I have used WRAP_CONTENT as height but I can't use FILL_PARENT.

If I use android:lines="1" then I simply can't see all the numbers. So how do I convert the double into scientific notation before displaying in the TextView?

Edit

I just discovered that it is being displayed in scientific notation but only for values greater than 10^12 But they're not just visible.

So i just it to display for values greater than 1E10.

Frozen Crayon
  • 5,172
  • 8
  • 36
  • 71
  • possible duplicate of [Format double value in scientific notation](http://stackoverflow.com/questions/2944822/format-double-value-in-scientific-notation) – Alexis C. May 31 '13 at 13:04

1 Answers1

1

convert double to scientific notation like that

public static String parseToCientificNotation(double result) {
    int cont = 0;
    java.text.DecimalFormat DECIMAL_FORMATER = new java.text.DecimalFormat("0.##");
    while (((int) result) != 0) {
        result/= 10;
        cont++;
    }
    return DECIMAL_FORMATER.format(result).replace(",", ".") + " x10^ -" + cont;

}

Sunil Kumar
  • 7,086
  • 4
  • 32
  • 50