活动转换后,EditText失去焦点

时间:2016-09-06 14:07:16

标签: android android-edittext activity-transition

我有活动A 活动B 。在他们的布局中他们都有一个工具栏,但活动B有一个EditText打击它的工具栏:

活动B:

<android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

  <android.support.design.widget.AppBarLayout
        android:id="@+id/activity_AppBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways">

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

            <include layout="@layout/view_toolbar"/>

            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/white"
                    android:orientation="vertical">

                <android.support.v7.widget.AppCompatEditText
                        ...
                        android:hint="@string/hint"
                        android:textColor="@color/colorPrimary"
                        android:textColorHint="@color/hint"
                        android:textCursorDrawable="@drawable/customCursor"/>

            </LinearLayout>
        </LinearLayout>

    </android.support.design.widget.CollapsingToolbarLayout>
  </android.support.design.widget.AppBarLayout>
  ... <!--the remaining of the layout-->
</android.support.design.widget.CoordinatorLayout>

活动A:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">

    <include layout="@layout/view_toolbar"/>
    ... <!--the remaining of the layout-->
</LinearLayout>

当我在没有过渡动画的情况下启动活动B 时,EditText会显示它的提示并且光标闪烁。 如果我通过转换开始活动B ,则EditText在我点击它之前不会显示提示和光标。

转换代码:

if (mUseCompatAnimation) {
     ViewCompat.setTransitionName(findViewById(R.id.activity_AppBarLayout), VIEW_FOR_TRANSITION);
}

VIEW_FOR_TRANSITION = 活动A 工具栏

我尝试过以编程方式请求重点,但它没有工作 我错过了什么或者这可能是个错误吗?

感谢。

0 个答案:

没有答案
相关问题