如何像官方 Facebook 应用程序一样获得手势视图

发布于 2024-09-17 08:44:58 字数 213 浏览 7 评论 0原文

我想在官方 Facebook 应用程序中实现通知视图的相同行为。 “通知”选项卡位于底部,可以通过手指拖/放至全屏。

我怎样才能做到这一点?

我已经通过 ViewFlipper 和 Animation 尝试过......但没有成功。

有谁知道我们该怎么做?

应用程序“Zedge”在“搜索”功能中具有相同的功能。 通过拖放,您可以打开“搜索”视图。

I want to implement the same behaviour of the notification view in the official Facebook app.
The "notifications" tab are at the bottom and can drag/drop via fingers to full screen.

How can i do that?

I've tried it via ViewFlipper and Animation.... But no success.

Does anyone know how we can do this?

The app "Zedge" has the same in the "search" function.
Via drag/drop you can open the "search" view.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小情绪 2024-09-24 08:44:58

这些应用程序使用 SlidingDrawer。 SlidingDrawer 将完成所有打开和关闭操作,您只需定义内容视图和句柄视图。

该视图也用作主屏幕上的应用程序抽屉。

Those Apps are using a SlidingDrawer. The SlidingDrawer will do all the opening and closing for you only have to define the content view and the view for the handle.

It is the same view that is also used as the application drawer on the home screen.

淡水深流 2024-09-24 08:44:58

此外,这里有一个如何使用 SlideingDrawer 的小演示:

/src - SliderActivity.java:

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.SlidingDrawer;
import android.widget.SlidingDrawer.OnDrawerCloseListener;
import android.widget.SlidingDrawer.OnDrawerOpenListener;

public class SliderActivity extends Activity {
    Button slideHandleButton;
    SlidingDrawer slidingDrawer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        slideHandleButton = (Button) findViewById(R.id.slideHandleButton);
        slidingDrawer = (SlidingDrawer) findViewById(R.id.SlidingDrawer);

        slidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
            @Override
            public void onDrawerOpened() {
                slideHandleButton.setBackgroundResource(R.drawable.arrowdown);
            }
        });

        slidingDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener() {
            @Override
            public void onDrawerClosed() {
                slideHandleButton.setBackgroundResource(R.drawable.arrowup);
            }
        });
    }
}

/res/layout - ma​​in.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:gravity="bottom">
    <SlidingDrawer android:layout_width="wrap_content"
        android:id="@+id/SlidingDrawer" android:handle="@+id/slideHandleButton"
        android:content="@+id/contentLayout" android:padding="10dip"
        android:layout_height="200dip">
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/slideHandleButton"
            android:background="@drawable/arrowup"></Button>
        <LinearLayout android:layout_width="wrap_content"
            android:id="@+id/contentLayout" android:orientation="vertical"
            android:gravity="center|top" android:padding="10dip"
            android:background="#505050" android:layout_height="wrap_content">
            <TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
                android:layout_height="fill_parent" android:layout_weight="8" android:text="Hello Slider"></TextView>
            <Button android:id="@+id/Button02" android:layout_weight="2" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="Do anything"></Button>
        </LinearLayout>
    </SlidingDrawer>
</LinearLayout>

另外,您需要 / 中的图像res/drawable 文件夹 - 在这种情况下就像 arrowup.pngarrowdown.png

如果你把它们放在一起,结果看起来像这样:

替代文字

替代文字

Additionally, here is a litte demo how the SlideingDrawer is used:

/src - SliderActivity.java:

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.SlidingDrawer;
import android.widget.SlidingDrawer.OnDrawerCloseListener;
import android.widget.SlidingDrawer.OnDrawerOpenListener;

public class SliderActivity extends Activity {
    Button slideHandleButton;
    SlidingDrawer slidingDrawer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        slideHandleButton = (Button) findViewById(R.id.slideHandleButton);
        slidingDrawer = (SlidingDrawer) findViewById(R.id.SlidingDrawer);

        slidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
            @Override
            public void onDrawerOpened() {
                slideHandleButton.setBackgroundResource(R.drawable.arrowdown);
            }
        });

        slidingDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener() {
            @Override
            public void onDrawerClosed() {
                slideHandleButton.setBackgroundResource(R.drawable.arrowup);
            }
        });
    }
}

/res/layout - main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:gravity="bottom">
    <SlidingDrawer android:layout_width="wrap_content"
        android:id="@+id/SlidingDrawer" android:handle="@+id/slideHandleButton"
        android:content="@+id/contentLayout" android:padding="10dip"
        android:layout_height="200dip">
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/slideHandleButton"
            android:background="@drawable/arrowup"></Button>
        <LinearLayout android:layout_width="wrap_content"
            android:id="@+id/contentLayout" android:orientation="vertical"
            android:gravity="center|top" android:padding="10dip"
            android:background="#505050" android:layout_height="wrap_content">
            <TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
                android:layout_height="fill_parent" android:layout_weight="8" android:text="Hello Slider"></TextView>
            <Button android:id="@+id/Button02" android:layout_weight="2" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="Do anything"></Button>
        </LinearLayout>
    </SlidingDrawer>
</LinearLayout>

Additionally you need to images in your /res/drawable folder - in this case like arrowup.png and arrowdown.png

If you put that all together it turns out to look like that:

alt text

alt text

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文