在Android中实现Globe-Weis File Folder [英] implement Globe-Weis File Folder in android

查看:60
本文介绍了在Android中实现Globe-Weis File Folder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现如下图所示的Globe-Weis文件夹,通过单击绿色按钮可以平滑地向上滚动,然后再次单击绿色按钮,文件夹页面可以平滑地向下滚动.

i want to implement Globe-Weis File Folder like picture below which by clicking on green button it scrolling smoothly up and by clicking on the green button again ,the folder page scrolling down smoothly.

到目前为止,我尝试将三个scrollView放在frameLayout中,然后打开和关闭它

what i try so far was putting three scrollView in a frameLayout , and to open and close it

 if (!underIsOpen) {
     ObjectAnimator
     .ofInt(sv_Under, "scrollY",
     findViewById(R.id.ll_under_botton).getTop())
     .setDuration(1000).start();
     underIsOpen = true;
     } else {

     ObjectAnimator
     .ofInt(sv_Under, "scrollY",
     findViewById(R.id.ll_under_s_part).getTop())
     .setDuration(1000).start();
     underIsOpen = false;

     }

但是它只能在顶部的scrollView上工作

but it just work on the scrollView which is on top

我的代码是:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test3);
    ll_under_s_part = (LinearLayout) findViewById(R.id.ll_under_s_part);
     sv_Under = (ScrollView) findViewById(R.id.scrollView1);
     sv_Mid = (ScrollView) findViewById(R.id.scrollView2);
     sv_Top = (ScrollView) findViewById(R.id.scrollView3);

}


public void onClick_under_left(View v) {
    Toast.makeText(getApplicationContext(), "under layout",
            Toast.LENGTH_SHORT).show();


     if (!underIsOpen) {
     ObjectAnimator
     .ofInt(sv_Under, "scrollY",
     findViewById(R.id.ll_under_botton).getTop())
     .setDuration(1000).start();
     underIsOpen = true;
     } else {

     ObjectAnimator
     .ofInt(sv_Under, "scrollY",
     findViewById(R.id.ll_under_s_part).getTop())
     .setDuration(1000).start();
     underIsOpen = false;

     }
}

public void onClick_mid_left(View v) {
    Toast.makeText(getApplicationContext(), "mid layout",
            Toast.LENGTH_SHORT).show();

}

public void onClick_top_left(View v) {

    Toast.makeText(getApplicationContext(), "top layout",
            Toast.LENGTH_SHORT).show();

     if (!topIsOpen) {
     ObjectAnimator
     .ofInt(sv_Top, "scrollY",
     findViewById(R.id.ll_top_botton).getTop())
     .setDuration(1000).start();
     topIsOpen = true;
     } else {

     ObjectAnimator
     .ofInt(sv_Top, "scrollY",
     findViewById(R.id.ll_top_s_part).getTop())
     .setDuration(1000).start();
     topIsOpen = false;

     }
}

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#00000000"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/ll_under_s_part"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:background="#ccff00"
                    android:orientation="vertical" >
                </LinearLayout>

                <Button
                    android:id="@+id/ll_under_botton"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:background="#519B57"
                    android:onClick="onClick_under_left"
                    android:orientation="vertical"
                    android:text="B T N" />

                <LinearLayout
                    android:id="@+id/ll_under_p_part"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:background="#edf5ee"
                    android:orientation="vertical" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_under_1"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:orientation="vertical" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_under_2"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:orientation="vertical" >
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="1000dp"
                    android:orientation="vertical" >
                </LinearLayout>
            </LinearLayout>
        </ScrollView>

        <ScrollView
            android:id="@+id/scrollView2"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#00000000"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/ll_mid_s_part"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:background="#00000000"
                    android:orientation="vertical" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_mid_3"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:orientation="vertical" >
                </LinearLayout>

                <Button
                    android:id="@+id/ll_mid_botton"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:background="#088da5"
                    android:onClick="onClick_mid_left"
                    android:orientation="vertical"
                    android:text="B T N" />

                <LinearLayout
                    android:id="@+id/ll_mid_p_part"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:background="#e6f3f6"
                    android:orientation="vertical" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_mid_1"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:orientation="vertical" >
                </LinearLayout>
            </LinearLayout>
        </ScrollView>

        <ScrollView
            android:id="@+id/scrollView3"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#00000000"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/ll_top_s_part"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:background="#00000000"
                    android:orientation="vertical"
                    android:visibility="visible" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_top_3"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:orientation="vertical" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_top_2"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:orientation="vertical" >
                </LinearLayout>

                <Button
                    android:id="@+id/ll_top_botton"
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:background="#D11141"
                    android:onClick="onClick_top_left"
                    android:orientation="vertical"
                    android:text="B T N" />

                <LinearLayout
                    android:id="@+id/ll_top_p_part"
                    android:layout_width="match_parent"
                    android:layout_height="300dp"
                    android:background="#fae7ec"
                    android:orientation="vertical" >
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </FrameLayout>
</LinearLayout>

我尝试的第二种方法是使用动画,但没有获得成功,我一直在寻找它:

the second way i tried was using animation but no success to result i am looking for :

    public void SlideUP(View view, Context context) {
    view.startAnimation(AnimationUtils.loadAnimation(context,
            R.anim.slid_up));
}

public void SlideDown(View view, Context context) {
    view.startAnimation(AnimationUtils.loadAnimation(context,
            R.anim.slid_down));
}

我可以实现此目的的任何其他方式吗?

any other way that i can implement this?

推荐答案

我不认为添加这样的做法可能会在具有滚动条的单个屏幕上布局是一个好主意,您可以应用简单的框架布局并相应地列出它们,并在单击时在任何所需的文件夹图标上,只需使其朝顶部设置动画,它还将显示该文件夹的内容.

I don't think adding so may layout on a single screen with scrollbars is a good idea, you can apply simple frame layouts and list them accordingly and when clicking on any of the desired folder icons just animate it towards top, and it will also show the content of the folder.

https://github.com/kikoso/Swipeable-Cards

您可以自定义此库来做到这一点,我做过类似的应用,并使用我的自定义更改应用了相同的库.

you could customize this library to do that, I have done a similar kind of app and applied the same library with my custom changes.

这篇关于在Android中实现Globe-Weis File Folder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆