共享元素转换 activity
Shared element transition activity
我在两个 activity 之间使用 shared element transition
。在新的 activity 中,我使用 shared preferences
设置共享视图的值。但是第一次在使用动画时没有显示这些值。从第二次开始,这些值就出现了。没有动画一切都很好。
Intent intent = new Intent(getActivity(), ProfileActivity.class);
ActivityOptionsCompat optionsCompat=ActivityOptionsCompat.makeSceneTransitionAnimation(mActivity,(View) v_profile,getString(R.string.mobile));
startActivity(intent,optionsCompat.toBundle());
并且在个人资料中 activity.xml
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="10dp"
android:layout_margin="10dp"
android:id="@+id/profile_Cardview"
android:transitionName="@string/mobile"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:id="@+id/mobile_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/mobile"
style="@style/light_text"
android:layout_marginBottom="4dp"
/>
<TextView
android:id="@+id/pf_tv_mobile_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginBottom="4dp"
android:singleLine="true"
style="@style/light_text"
/>
<View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@color/grey"
android:layout_marginBottom="8dp"
/>
<TextView
android:id="@+id/pf_tv_agency_label_"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/agency_label"
style="@style/light_text"
android:layout_marginBottom="4dp"
/>
<EditText
android:id="@+id/pf_tv_agency_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginBottom="4dp"
android:singleLine="true"
android:inputType="text"
style="@style/normal_text"
/>
<TextView
android:id="@+id/pf_tv_mobile_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/paytm"
style="@style/light_text"
android:layout_marginBottom="4dp"
/>
<EditText
android:id="@+id/pf_tv_paytm_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginBottom="4dp"
android:singleLine="true"
android:inputType="text"
style="@style/normal_text"
/>
<!-- <View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@color/grey"
android:layout_marginBottom="8dp"
/>-->
<TextView
android:id="@+id/pf_tv_agency_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/bhim_label"
style="@style/light_text"
android:layout_marginBottom="2dp"
/>
<EditText
android:id="@+id/pf_tv_bhim_no"
style="@style/normal_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:layout_marginBottom="8dp"
android:inputType="text"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
我正在从 sharedpreferences 设置 edittext 值。
我已经解决了。一旦我关注第一个编辑文本,数据就会显示出来
rootView.(findViewById(R.id.pf_tv_agency_name)).requestFocus()
在 onActivityCreated()
中。这些字段即将被填满。
我在两个 activity 之间使用 shared element transition
。在新的 activity 中,我使用 shared preferences
设置共享视图的值。但是第一次在使用动画时没有显示这些值。从第二次开始,这些值就出现了。没有动画一切都很好。
Intent intent = new Intent(getActivity(), ProfileActivity.class);
ActivityOptionsCompat optionsCompat=ActivityOptionsCompat.makeSceneTransitionAnimation(mActivity,(View) v_profile,getString(R.string.mobile));
startActivity(intent,optionsCompat.toBundle());
并且在个人资料中 activity.xml
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="10dp"
android:layout_margin="10dp"
android:id="@+id/profile_Cardview"
android:transitionName="@string/mobile"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:id="@+id/mobile_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/mobile"
style="@style/light_text"
android:layout_marginBottom="4dp"
/>
<TextView
android:id="@+id/pf_tv_mobile_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginBottom="4dp"
android:singleLine="true"
style="@style/light_text"
/>
<View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@color/grey"
android:layout_marginBottom="8dp"
/>
<TextView
android:id="@+id/pf_tv_agency_label_"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/agency_label"
style="@style/light_text"
android:layout_marginBottom="4dp"
/>
<EditText
android:id="@+id/pf_tv_agency_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginBottom="4dp"
android:singleLine="true"
android:inputType="text"
style="@style/normal_text"
/>
<TextView
android:id="@+id/pf_tv_mobile_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/paytm"
style="@style/light_text"
android:layout_marginBottom="4dp"
/>
<EditText
android:id="@+id/pf_tv_paytm_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_marginBottom="4dp"
android:singleLine="true"
android:inputType="text"
style="@style/normal_text"
/>
<!-- <View
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@color/grey"
android:layout_marginBottom="8dp"
/>-->
<TextView
android:id="@+id/pf_tv_agency_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/bhim_label"
style="@style/light_text"
android:layout_marginBottom="2dp"
/>
<EditText
android:id="@+id/pf_tv_bhim_no"
style="@style/normal_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:singleLine="true"
android:layout_marginBottom="8dp"
android:inputType="text"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
我正在从 sharedpreferences 设置 edittext 值。
我已经解决了。一旦我关注第一个编辑文本,数据就会显示出来
rootView.(findViewById(R.id.pf_tv_agency_name)).requestFocus()
在 onActivityCreated()
中。这些字段即将被填满。