小编Pau*_*Zin的帖子

TextInputLayout提示重叠问题

我正在使用Android Design Library中的TextInputLayout在EditText上显示标签.

问题是当我开始活动时,EditText提示(标签)文本与实际文本重叠(一秒钟),然后返回到它自己的位置(在EditText的顶部).

为了说明这个问题,我录制了一个简短的示例视频:https://youtu.be/gy0CzcYggxU

这是我的activity.xml:

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_margin="16dp"
  android:orientation="vertical">

<android.support.design.widget.TextInputLayout
    android:id="@+id/firstNameTextInputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp">

  <EditText
      android:id="@+id/firstNameEditText"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="@string/first_name"
      android:inputType="textCapWords"
      android:textColor="@color/textPrimary"
      android:textColorHint="@color/textSecondary"
      android:textSize="16sp"
      android:theme="@style/CustomEditText"/>
</android.support.design.widget.TextInputLayout>


<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="24dp">

  <EditText
      android:id="@+id/lastNameEditText"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="@string/last_name"
      android:inputType="textCapWords"
      android:textColor="@color/textPrimary"
      android:textColorHint="@color/textSecondary"
      android:textSize="16sp"
      android:theme="@style/CustomEditText"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

android android-support-library

16
推荐指数
1
解决办法
4245
查看次数

使用倒数平方和计算PI

我需要使用以下公式以预定义的精度计算PI:

在此输入图像描述

所以我最终得到了这个解决方案.

private static double CalculatePIWithPrecision(int presicion)
{
    if (presicion == 0)
    {
        return PI_ZERO_PRECISION;
    }

    double sum = 0;

    double numberOfSumElements = Math.Pow(10, presicion + 2);

    for (double i = 1; i < numberOfSumElements; i++)
    {
        sum += 1 / (i * i);
    }

    double pi = Math.Sqrt(sum * 6);
    return pi;
}
Run Code Online (Sandbox Code Playgroud)

所以这是正确的,但我遇到了效率问题.精度值为8或更高时,它非常慢.

是否有更好(更快!)的方法来使用该公式计算PI?

c# math pi

6
推荐指数
1
解决办法
430
查看次数

标签 统计

android ×1

android-support-library ×1

c# ×1

math ×1

pi ×1