作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对如何使用 transitionSet 感到困惑。这是我的定义:
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android" android:transitionOrdering="sequential">
<slide android:slideEdge="bottom" android:startDelay="0">
<targets>
<target android:targetId="@id/action_save" />
</targets>
</slide>
<slide android:slideEdge="top">
<targets>
<target android:targetId="@id/image_album_background" />
</targets>
</slide>
<slide
android:duration="500"
android:slideEdge="bottom">
<targets>
<target android:targetId="@id/fields_container" />
</targets>
</slide>
</transitionSet>
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android" android:transitionOrdering="sequential">
<slide android:slideEdge="top">
<targets>
<target android:targetId="@id/image_album_background" />
</targets>
</slide>
<slide android:slideEdge="bottom" android:startDelay="0">
<targets>
<target android:targetId="@id/action_save" />
</targets>
</slide>
<slide
android:duration="500"
android:slideEdge="bottom">
<targets>
<target android:targetId="@id/fields_container" />
</targets>
</slide>
</transitionSet>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Picture -->
<RelativeLayout
android:id="@+id/image_album_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff000000">
<ImageView
android:id="@+id/image_album"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:contentDescription="No art"
android:maxHeight="320dp"
android:maxWidth="320dp"
android:src="@drawable/ic_noart"
android:transitionName="transition_album_cover"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/btn_img_marker"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignEnd="@+id/image_album"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/image_album"
android:background="#ff56bb21" />
</RelativeLayout>
<LinearLayout
android:id="@+id/fields_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/image_album_background"
android:background="#ffffffff"
android:orientation="vertical"
android:padding="@dimen/frame_margin">
<CheckBox
android:id="@+id/cb_embed_art"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/label_embed_art" />
<TextView
android:id="@+id/text_filepath"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="/mnt/data/path/to/file/audio.mp3" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/fields_container"
android:background="#ffffffff"
android:padding="24dp">
<!-- Title -->
<LinearLayout
android:id="@+id/title_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_title" />
<EditText
android:id="@+id/edit_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="text" />
</LinearLayout>
<!-- Artist -->
<LinearLayout
android:id="@+id/artist_row"
style="@style/input_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title_row"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_artist" />
<AutoCompleteTextView
android:id="@+id/edit_artist"
style="?android:editTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</LinearLayout>
<!-- Album artist -->
<LinearLayout
android:id="@+id/album_artist_row"
style="@style/input_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/artist_row"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_album_artist" />
<AutoCompleteTextView
android:id="@+id/edit_album_artist"
style="?android:editTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</LinearLayout>
<!-- Album -->
<LinearLayout
android:id="@+id/album_row"
style="@style/input_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/album_artist_row"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_album" />
<AutoCompleteTextView
android:id="@+id/edit_album"
style="?android:editTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</LinearLayout>
<LinearLayout
android:id="@+id/two_column_row1"
style="@style/input_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/album_row"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_genre" />
<AutoCompleteTextView
android:id="@+id/edit_genre"
style="?android:editTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</LinearLayout>
<LinearLayout
style="@style/input_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_year" />
<EditText
android:id="@+id/edit_year"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_track_no" />
<EditText
android:id="@+id/edit_track_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</LinearLayout>
<LinearLayout
style="@style/input_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_track_total" />
<EditText
android:id="@+id/edit_track_total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/input_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/two_column_row1"
android:orientation="horizontal">
<TextView
style="@style/label"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/label_comment" />
<EditText
android:id="@+id/edit_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:minLines="5" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/action_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/ic_action_save"
fab:fab_colorNormal="@color/accent_shade"
fab:fab_colorRipple="#66FF9800" />
</FrameLayout>
String transitionName = "transition_album_cover";
if (AnimationViews.albumCover != null) {
fragmentTx.addSharedElement(AnimationViews.albumCover, transitionName);
}
TransitionInflater inflater = TransitionInflater.from(this);
editorFragment.setEnterTransition(inflater.inflateTransition(R.transition.editor_fragment_enter));
最佳答案
能够使所有作为 subview 的转换工作是很棘手的。因为它取决于ViewGroup
(父 View )该 subview 。
引自 jimulabs :
- If the background of a
ViewGroup
is set (even if it’sandroid:color/transparent
), the transition system will treat theViewGroup
as a single view and ignore its children. Thus, any transitions will only run on theViewGroup
, instead of its children individually; if a transition has its target set to one of the children only, the transition will not run at all.- Conversely, if a
ViewGroup
does not have a background (or it’s@null
), transitions will run for all its individual children; if a transition has its target set to theViewGroup
, the transition will not run at all.- This does NOT happen if you run
beginDelayedTransition()
in normal cases such as setting the visibility of views in aOnClickListener
.
ViewGroup#setTransitionGroup(boolean)
使其工作。我无法让它工作。我曾尝试在屏幕的父布局上使用此方法。所以我不得不坚持使用
java
所有代码
transitionSet
耗时的目标。
关于android-5.0-lollipop - Android transition 不关心 transitionSet 中的 targetId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28260061/
我一直在学习如何创建自定义 ArrayAdapter 并熟悉重写 ArrayAdapter 的 getViewTypeCount 和 getItemViewType 方法。 为什么 Android V
我是一名优秀的程序员,十分优秀!