我目前正在使用umano slidinguppanel进行我的一个测试项目,但是我确实遇到了一个问题,我想让面板只在我按下(不是点击)并拖动某个图像或者点击按钮本身它会扩展。后者有点容易实现,但对于媒体而言,我很难实现它。
这里有一个更好的视觉效果是我的面板XML:
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:background="#00ffffff"
sothree:panelHeight="120dp"
sothree:shadowHeight="0dp"
sothree:overlay="true"
sothree:fadeColor="@android:color/transparent">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView2"
android:src="@drawable/test_img"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/ic_menu"
android:src="@drawable/menu"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:onClick="showDrawer" />
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#00ffffff">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#00ffffff"
android:id="@+id/transparent_panel">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/ic_menu2"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:onClick="showDrawer"
android:visibility="gone"
android:src="#00ffffff" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img_expand"
android:src="@drawable/img_expand" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66ffffff"
android:id="@+id/pager_container">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title"
android:background="@color/yellow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"/>
</android.support.v4.view.ViewPager>
</LinearLayout>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
这里我有一个带图像的面板,我想在扩展抽屉时成为手柄,在我的代码中我试图实现这个:
ImageView img_expand = (ImageView) findViewById(R.id.img_expand);
slideLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
slideLayout.setSlidingEnabled(false);
img_expand.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.e("Test", String.valueOf(event));
Log.e("Test2", String.valueOf(event.ACTION_DOWN));
Log.e("Test3", String.valueOf(event.getAction()));
Log.e("Test4", String.valueOf(MotionEvent.ACTION_DOWN));
Log.e("Test5", String.valueOf(MotionEvent.ACTION_MOVE));
if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN) {
slideLayout.setSlidingEnabled(true);
return true;
}else{
slideLayout.setSlidingEnabled(false);
return false;
}
}
});
可悲的是,它并没有像我预期的那样奏效。希望有人可以指导我。 :d