Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions app/src/main/java/com/desnyki/infinitymenuexample/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.desnyki.infinitymenuexample;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

Expand All @@ -14,13 +12,15 @@

public class MainActivity extends AppCompatActivity {

RelativeLayout bar1;
RelativeLayout bar2;
RelativeLayout bar3;
RelativeLayout bar4;
ChildScrollView childScrollView;
RootScrollView rootScrollView;
final LinearLayout[] childContainer = new LinearLayout[5]; //used to cache and access child views, no children have been hurt in this container
private RelativeLayout bar1;
private RelativeLayout bar2;
private RelativeLayout bar3;
private RelativeLayout bar4;
private ChildScrollView childScrollView;
private RootScrollView rootScrollView;

//used to cache and access child views, no children have been hurt in this container
private final LinearLayout[] childContainer = new LinearLayout[5];

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -33,40 +33,46 @@ protected void onCreate(Bundle savedInstanceState) {
childScrollView.setBackgroundScrollView(rootScrollView);
childScrollView.setCloseDistance(50);

final ViewGroup.LayoutParams params
= new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

bar1 = (RelativeLayout) findViewById(R.id.bar1);
childContainer[0]=(LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
childContainer[0] = (LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
bar1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
childScrollView.addView(childContainer[0], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
childScrollView.addView(childContainer[0], 0, params);
childScrollView.openWithAnim(bar1,true,false);
}
});

bar2 = (RelativeLayout) findViewById(R.id.bar2);
childContainer[1] = (LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
bar2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
childScrollView.addView(childContainer[1], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
childScrollView.addView(childContainer[1], 0, params);
childScrollView.openWithAnim(bar2, false, true);
}
});

bar3 = (RelativeLayout) findViewById(R.id.bar3);
childContainer[2] = (LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
bar3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
childScrollView.addView(childContainer[2], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
childScrollView.addView(childContainer[2], 0, params);
childScrollView.openWithAnim(bar3, false, true);
}
// }
});

bar4 = (RelativeLayout) findViewById(R.id.bar4);
childContainer[3] = (LinearLayout) getLayoutInflater().inflate(R.layout.my_menu_item, null);
bar4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
childScrollView.addView(childContainer[3], 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
childScrollView.addView(childContainer[3], 0, params);
childScrollView.openWithAnim(bar4, false, true);
}
});
Expand Down
Loading