san*_*o21 5 android-5.0-lollipop
我对如何使用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>
Run Code Online (Sandbox Code Playgroud)
这样,所有视图都将从底部边缘滑动.但是,如果我将订单更改为:
<?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>
Run Code Online (Sandbox Code Playgroud)
然后,所有都将从顶部边缘滑动.
似乎Android只关心第一次转换.
更新:这是布局:
<?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>
Run Code Online (Sandbox Code Playgroud)
这是如何打开布局:
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));
Run Code Online (Sandbox Code Playgroud)
我刚刚尝试过这个,它对我来说效果很好,所以我必须认为它与你的具体目标有关。我的猜测是 image_album_background 包含 action_save 和 fields_container。如果是这样,这两个视图仍然会在它们的容器内滑动。
解决这个问题的简单方法是将 image_album_background 移动到其他两个的同级而不是父级中。如果您还没有能够执行此操作的容器(例如 LinearLayout),则可以使用一个额外的级别来完成此操作:
<FrameLayout ...>
<ImageView android:id="@+id/image_album_background"/>
<other views.../>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2093 次 |
| 最近记录: |