Android 右滑入式面板,类似于WunderList应用程序
我想看看有没有人知道神童是怎么做到的?见图: 基本上,如果你点击你添加的任何列表项,这个抽屉就会弹出来显示项目的详细信息。在本例中,我随机添加了一个项目,显然称为“Rgh”。点击它,它从右边滑出。你可以滑动它,它会回到它的来源 我原以为它是一个Android 右滑入式面板,类似于WunderList应用程序,android,Android,我想看看有没有人知道神童是怎么做到的?见图: 基本上,如果你点击你添加的任何列表项,这个抽屉就会弹出来显示项目的详细信息。在本例中,我随机添加了一个项目,显然称为“Rgh”。点击它,它从右边滑出。你可以滑动它,它会回到它的来源 我原以为它是一个SliderMenu库,也许像jfeinstein10一样,但Wunderlist已经在左边有了一个滑块。右边那个(图中)的动作完全不同。它更大,而不是推动内容,它只是在过去的活动(或片段?)。它不能通过刷卡打开(只能关闭)。我知道,对于jfeinsti
SliderMenu
库,也许像jfeinstein10一样,但Wunderlist已经在左边有了一个滑块。右边那个(图中)的动作完全不同。它更大,而不是推动内容,它只是在过去的活动(或片段?)。它不能通过刷卡打开(只能关闭)。我知道,对于jfeinstien的,你不能做任何事情——右和左必须非常相似(除非你把它再分类)
我知道有一种叫做滑动抽屉的东西,但我几乎看不到这种东西被使用了,这就是它吗?实现此功能的最佳方式是什么?线性布局加动画。我在我的应用程序中也做了类似的操作。
甚至不用碎片。使用动画类,代码如下所示:
/*
This class is responsible for showing the sliding animation
*/
public class SlideAnim extends Animation {
int targetWidth;
View slideView;
ImageView imageView;
boolean close;
public SlideAnim(View _v, boolean _close, int _maxWidth, ImageView imageView) {
this.slideView = _v;
this.imageView = imageView;
targetWidth = _maxWidth;
close = _close;
}
protected void applyTransformation(float interpolatedTime, Transformation t) {
int newWidth;
if (!close) {
newWidth = (int) (targetWidth * interpolatedTime);
} else {
newWidth = (int) (targetWidth * (1 - interpolatedTime));
}
slideView.getLayoutParams().width = newWidth;
slideView.requestLayout();
imageView.setImageResource(slideView.getWidth() > 0 ? R.drawable.purple_arrow_right : R.drawable.purple_arrow_left);
}
public void initalize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
public boolean willChangeBounds() {
return true;
}
}
以下是我如何从另一个活动调用动画:
SlideAnim slideAnim = new SlideAnim(trendingListLayout, false, maxListWidth, imageView);
slideAnim.setDuration(500);
slideAnim.reset();
trendingListLayout.clearAnimation();
trendingListLayout.startAnimation(slideAnim);
我正在为线性布局设置动画:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/top_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.eazyigz.views.EazyigzImageView
android:id="@+id/whole_screen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<View
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/explore_expander"
android:layout_width="30dp"
android:layout_height="fill_parent"
android:background="@color/eazyigz_bg_primary"
android:orientation="horizontal"
android:visibility="invisible" >
<ImageView
android:id="@+id/explore_expander_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="@drawable/purple_arrow_left" />
</LinearLayout>
<!-- List Layout -->
<LinearLayout
android:id="@+id/explore_list_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:paddingTop="50dp"
android:background="@color/eazyigz_bg_secondary"
android:orientation="vertical"
android:visibility="invisible" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="0dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal|center_vertical"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit ="marquee_forever"
android:scrollHorizontally="true"
android:text="@string/top_trending"
android:textColor="@color/eazyigz_green"
android:textSize="30sp" />
<ProgressBar
android:id="@+id/explore_spinner"
android:layout_width="50dp"
android:layout_height="45dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:indeterminateDrawable="@drawable/progress_spinner"
android:visibility="visible"
android:layout_gravity="center_horizontal|center_vertical"/>
<ListView
android:id="@+id/explore_list"
style="@style/EazyigzListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="#0000"
android:layout_marginLeft="10dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="50dp"
android:paddingLeft="20dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" />
<Button
android:id="@+id/eazyigz_play"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:padding="5dp"
android:text="@string/playing"
android:textColor="@color/eazyigz_white"
android:textSize="36sp"
android:visibility="gone"/>
<Button
android:id="@+id/eazyigz_create"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:padding="5dp"
android:text="@string/create"
android:textColor="@color/eazyigz_white"
android:textSize="36sp" />
<Button
android:id="@+id/eazyigz_explore"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:padding="5dp"
android:text="@string/explore"
android:textColor="@color/eazyigz_white"
android:textSize="36sp" />
<Button
android:id="@+id/eazyigz_listen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="50dp"
android:paddingTop="5dp"
android:text="@string/stations"
android:textColor="@color/eazyigz_white"
android:textSize="36sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" />
</LinearLayout>
</merge>
浏览列表布局是设置动画的地方
请参阅屏幕外观视频:线性布局加动画。我在我的应用程序中也做了类似的操作。
甚至不用碎片。使用动画类,代码如下所示:
/*
This class is responsible for showing the sliding animation
*/
public class SlideAnim extends Animation {
int targetWidth;
View slideView;
ImageView imageView;
boolean close;
public SlideAnim(View _v, boolean _close, int _maxWidth, ImageView imageView) {
this.slideView = _v;
this.imageView = imageView;
targetWidth = _maxWidth;
close = _close;
}
protected void applyTransformation(float interpolatedTime, Transformation t) {
int newWidth;
if (!close) {
newWidth = (int) (targetWidth * interpolatedTime);
} else {
newWidth = (int) (targetWidth * (1 - interpolatedTime));
}
slideView.getLayoutParams().width = newWidth;
slideView.requestLayout();
imageView.setImageResource(slideView.getWidth() > 0 ? R.drawable.purple_arrow_right : R.drawable.purple_arrow_left);
}
public void initalize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
public boolean willChangeBounds() {
return true;
}
}
以下是我如何从另一个活动调用动画:
SlideAnim slideAnim = new SlideAnim(trendingListLayout, false, maxListWidth, imageView);
slideAnim.setDuration(500);
slideAnim.reset();
trendingListLayout.clearAnimation();
trendingListLayout.startAnimation(slideAnim);
我正在为线性布局设置动画:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/top_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.eazyigz.views.EazyigzImageView
android:id="@+id/whole_screen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<View
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/explore_expander"
android:layout_width="30dp"
android:layout_height="fill_parent"
android:background="@color/eazyigz_bg_primary"
android:orientation="horizontal"
android:visibility="invisible" >
<ImageView
android:id="@+id/explore_expander_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="@drawable/purple_arrow_left" />
</LinearLayout>
<!-- List Layout -->
<LinearLayout
android:id="@+id/explore_list_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:paddingTop="50dp"
android:background="@color/eazyigz_bg_secondary"
android:orientation="vertical"
android:visibility="invisible" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="0dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal|center_vertical"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit ="marquee_forever"
android:scrollHorizontally="true"
android:text="@string/top_trending"
android:textColor="@color/eazyigz_green"
android:textSize="30sp" />
<ProgressBar
android:id="@+id/explore_spinner"
android:layout_width="50dp"
android:layout_height="45dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:indeterminateDrawable="@drawable/progress_spinner"
android:visibility="visible"
android:layout_gravity="center_horizontal|center_vertical"/>
<ListView
android:id="@+id/explore_list"
style="@style/EazyigzListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="#0000"
android:layout_marginLeft="10dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="50dp"
android:paddingLeft="20dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" />
<Button
android:id="@+id/eazyigz_play"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:padding="5dp"
android:text="@string/playing"
android:textColor="@color/eazyigz_white"
android:textSize="36sp"
android:visibility="gone"/>
<Button
android:id="@+id/eazyigz_create"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:padding="5dp"
android:text="@string/create"
android:textColor="@color/eazyigz_white"
android:textSize="36sp" />
<Button
android:id="@+id/eazyigz_explore"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:padding="5dp"
android:text="@string/explore"
android:textColor="@color/eazyigz_white"
android:textSize="36sp" />
<Button
android:id="@+id/eazyigz_listen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/eazyigz_button"
android:drawablePadding="0dp"
android:gravity="left|center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="50dp"
android:paddingTop="5dp"
android:text="@string/stations"
android:textColor="@color/eazyigz_white"
android:textSize="36sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" />
</LinearLayout>
</merge>
浏览列表布局是设置动画的地方
查看屏幕外观的视频:你好,Kicking莴苣
嗨,伊戈尔
我们需要一个来自右边的面板,位于应用程序其余部分的顶部,并且我们希望它是“可滑动的”,包括基本的“最近点”打开或关闭以及加速度跟踪,以决定如果滑动进行到一半该怎么办
我们最初尝试使用Android的SlidingDrawer,但首先是它的不受欢迎,然后仅仅从侧面的旋钮滑动的能力+它不太完美的性能让我们考虑做其他事情
我们称之为SlidingLayer,我们很快计划将其开源。我们只是想确保添加一对调整,使您不必深入到代码中不必要的部分(即:轻松添加阴影),就可以获得一些灵活性。
同时,如果这对你有帮助的话,我们在很大程度上基于滑动菜单操作(我们喜欢它的工作方式)。
它基本上是一个容器(从一个RelativeLayout扩展而来,可能会变成一个视图组-我很想讨论这个问题-RelativeLayout->pro:多功能,避免额外的视图。缺点:你可能需要一个不同的布局)。通过覆盖和分析onInterceptTouchEvent和onTouchEvent中的触摸,可以跟随手指的移动->滚动(使用scrollTo)。
这相对容易。我会鼓励你去做的。关于这两种方法已经有了很好的教程和代码示例
尽管如此,如果你不想承担责任,我会在我们准备好的时候告诉你。
我会在这里做一个简短的跟进,以防你决定去做
祝你一切顺利。你好,Kicking莴苣
嗨,伊戈尔
我们需要一个来自右边的面板,位于应用程序其余部分的顶部,并且我们希望它是“可滑动的”,包括基本的“最近点”打开或关闭以及加速度跟踪,以决定如果滑动进行到一半该怎么办
我们最初尝试使用Android的SlidingDrawer,但首先是它的不受欢迎,然后仅仅从侧面的旋钮滑动的能力+它不太完美的性能让我们考虑做其他事情
我们称之为SlidingLayer,我们很快计划将其开源。我们只是想确保添加一对调整,使您不必深入到代码中不必要的部分(即:轻松添加阴影),就可以获得一些灵活性。
同时,如果这对你有帮助的话,我们在很大程度上基于滑动菜单操作(我们喜欢它的工作方式)。
它基本上是一个容器(从一个RelativeLayout扩展而来,可能会变成一个视图组-我很想讨论这个问题-RelativeLayout->pro:多功能,避免额外的视图。缺点:你可能需要一个不同的布局)。通过覆盖和分析onInterceptTouchEvent和onTouchEvent中的触摸,可以跟随手指的移动->滚动(使用scrollTo)。
这相对容易。我会鼓励你去做的。关于这两种方法已经有了很好的教程和代码示例
尽管如此,如果你不想承担责任,我会在我们准备好的时候告诉你。
我会在这里做一个简短的跟进,以防你决定去做
祝您一切顺利。可能是浏览者,不,等等,可能不是。但是如果你以前没有看过,那就值得一看!可能是浏览者,不,等等,可能不是。但是如果你以前没有看过,那就值得一看!它是一个片段还是一个活动?假设Framelayout?也为碎片。。您是否使用片段事务并以这种方式添加动画?它是片段还是活动?假设Framelayout?也为碎片。。您是否使用片段事务并以这种方式添加动画?作为此答案的补充,此滑动层的代码已经开源。在GitHub中查看谢谢你非常感谢我很快就要写我的