2016-01-13 27 views
1

我想要實現Globe-Weis文件夾,就像下面的圖片一樣,通過點擊綠色按鈕它平滑地滾動並再次點擊綠色按鈕,文件夾頁面順利地向下滾動。在android中執行Globe-Weis文件夾

enter image description here

enter image description here

我怎麼努力,到目前爲止是的把三scrollViewframeLayout,並打開和關閉

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工作,這是對頂部

我的代碼是:

@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> 

我試圖用動畫,但沒有成功,導致我的第二個方法在尋找:

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)); 
} 

任何其他方式,我可以執行這個?

回答

0

我不認爲增加如此可能在單個滾動條屏幕上的佈局是一個好主意,你可以應用簡單的框架佈局,並相應地列出它們,當點擊任何所需的文件夾圖標只是向頂部,它也會顯示文件夾的內容。

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

你可以自定義這個庫來做到這一點,我已經做了類似的一類應用,並與我的自定義更改應用於同一個庫。

相關問題