您可以使用< code>DecimalFormat
DecimalFormat format = new DecimalFormat("##.#");
String formattedText = format.format(025.0);
editText.setText(formattedText);
您将在编辑文本
中获得结果为25.0
你可以在xml文件中设置它。比如
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageView1"
android:layout_below="@+id/imageView1"
android:layout_marginLeft="20dp"
android:layout_marginTop="54dp"
android:ems="10"
android:inputType="numberDecimal" >