在ListItem触摸事件后显示另一个片段

时间:2015-04-16 16:46:12

标签: android

我显示了ListView中包含的FrameLayout。我想做的是将片段从底部移动到已触摸的列表项。

作为第一次迭代,我很高兴知道如何将一个片段绘制在另一个片段上以及如何移动它......

1 个答案:

答案 0 :(得分:1)

我做了你需要的东西,这是我之前的项目。

布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
    android:id="@+id/rlt"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/lv_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </ListView>
</RelativeLayout>
<!-- this frame is invisible -->
<FrameLayout
    android:id="@+id/fragInvi"
    android:visibility="invisible"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:background="#253">
</FrameLayout> </LinearLayout>

onItemClickListener:

if (fragInvi.getVisibility() != View.VISIBLE) {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        fragInvi.setVisibility(View.VISIBLE);
        fragInvi.animate().translationY(-fragInvi.getHeight()).setDuration(500);
     }
 }