Exemplo n.º 1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_draw, container, false);
    frame_draw_layout = (LinearLayout) view.findViewById(R.id.frame_draw_layout);
    slidingPaneLayout = new SlidingPaneLayout(getActivity());
    try {
      Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
      f_overHang.setAccessible(true);
      f_overHang.set(slidingPaneLayout, 0);
      slidingPaneLayout.setPanelSlideListener(this);
      slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));
    } catch (Exception e) {
      e.printStackTrace();
    }

    View leftView = new View(getActivity());
    leftView.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    leftView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    slidingPaneLayout.addView(leftView, 0);

    ViewGroup decor = (ViewGroup) getActivity().getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    decor.removeView(decorChild);
    decor.addView(slidingPaneLayout);
    slidingPaneLayout.addView(decorChild, 1);
    return view;
  }
 private void initData() {
   String[] strArr = getResources().getStringArray(R.array.url_arr);
   ArrayAdapter<String> adapter =
       new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, strArr);
   mListView.setAdapter(adapter);
   mListView.setOnItemClickListener(this);
   mWebview.setWebViewClient(new MyWebviewClient());
   mSlidingPaneLayout.setPanelSlideListener(this);
 }
Exemplo n.º 3
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    setContentView(R.layout.slidingpane_main_layout);
    Injector.get(this).inject(); // init views
    menuFragment = new MenuFragment();
    contentFragment = new HomeFragment();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.slidingpane_menu, menuFragment);
    transaction.replace(R.id.slidingpane_content, contentFragment);
    transaction.commit();
    maxMargin = displayMetrics.heightPixels / 10;
    slidingPaneLayout.setPanelSlideListener(
        new PanelSlideListener() {
          @Override
          public void onPanelSlide(View panel, float slideOffset) {
            // TODO Auto-generated method stub
            //				int contentMargin = (int) (slideOffset * maxMargin);
            //				FrameLayout.LayoutParams contentParams = contentFragment
            //						.getCurrentViewParams();
            //				contentParams.setMargins(0, contentMargin, 0, contentMargin);
            //				contentFragment.setCurrentViewPararms(contentParams);
            //
            //				float scale = 1 - ((1 - slideOffset) * maxMargin * 2)
            //						/ (float) displayMetrics.heightPixels;
            //				Log.e("scale", scale + "sss" + slideOffset + "");
            //				menuFragment.getCurrentView().setScaleX(scale);// 设置缩放的基准点
            //				menuFragment.getCurrentView().setScaleY(scale);// 设置缩放的基准点
            //				menuFragment.getCurrentView().setPivotX(0);// 设置缩放和选择的点
            //				menuFragment.getCurrentView().setPivotY(
            //						displayMetrics.heightPixels / 2);
            //				menuFragment.getCurrentView().setAlpha(slideOffset);
          }

          @Override
          public void onPanelOpened(View panel) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onPanelClosed(View panel) {
            // TODO Auto-generated method stub

          }
        });
  }
  @Override
  protected void initViews(Bundle var) {
    slidingLeftFragment.setSlidingLeftListener(this);

    slidingPaneLayout.openPane();
    slidingPaneLayout.setPanelSlideListener(
        new SlidingPaneLayout.PanelSlideListener() {
          @Override
          public void onPanelSlide(View panel, float slideOffset) {
            if (slidingLeftFragment.isAnimation()) {
              if (mMenuPanel == null) {
                final int childCount = slidingPaneLayout.getChildCount();
                for (int i = 0; i < childCount; i++) {
                  final View child = slidingPaneLayout.getChildAt(i);
                  if (child != panel) {
                    mMenuPanel = child;
                    break;
                  }
                }
              }
              final float scaleLeft = 1 - 0.3f * (1 - slideOffset);
              mMenuPanel.setPivotX(-0.3f * mMenuPanel.getWidth());
              mMenuPanel.setPivotY(mMenuPanel.getHeight() / 2f);
              mMenuPanel.setScaleX(scaleLeft);
              mMenuPanel.setScaleY(scaleLeft);

              final float scale = 1 - 0.2f * slideOffset;
              panel.setPivotX(0);
              panel.setPivotY(panel.getHeight() / 2.0f);
              panel.setScaleX(scale);
              panel.setScaleY(scale);
            }
          }

          @Override
          public void onPanelOpened(View panel) {
            slidingLeftFragment.setHasOptionsMenu(false);
          }

          @Override
          public void onPanelClosed(View panel) {
            slidingLeftFragment.setHasOptionsMenu(true);
          }
        });
  }
Exemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_my);
    // actionBar=getSupportActionBar();
    checkPlayServices();
    int dpValue = 50; // margin in dips
    float d = this.getResources().getDisplayMetrics().density;
    final int margin = (int) (dpValue * d);

    mSlidingLayout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);
    final View Fmargin = mSlidingLayout.findViewById(R.id.content_pane);
    final ViewGroup.MarginLayoutParams lp =
        (ViewGroup.MarginLayoutParams) Fmargin.getLayoutParams();

    mSlidingLayout.setPanelSlideListener(
        new SlidingPaneLayout.PanelSlideListener() {
          @Override
          public void onPanelSlide(View panel, float slideOffset) {
            if (add) {

            } else {

            }
          }

          @Override
          public void onPanelOpened(View panel) {
            getSupportFragmentManager()
                .findFragmentById(R.id.content_pane)
                .setHasOptionsMenu(false);
            getSupportFragmentManager().findFragmentById(R.id.list_pane).setHasOptionsMenu(true);
            // actionBar.removeAllTabs();
            // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            add = true;
            lp.setMargins(margin, 0, 0, 0);
            Fmargin.setLayoutParams(lp);
          }

          @Override
          public void onPanelClosed(View panel) {
            getSupportFragmentManager().findFragmentById(R.id.content_pane).setHasOptionsMenu(true);
            getSupportFragmentManager().findFragmentById(R.id.list_pane).setHasOptionsMenu(false);
            if (!MyListFragment.contatti) {
              // actionBar.removeAllTabs();
              // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
              add = true;
              lp.setMargins(margin, 0, 0, 0);
              Fmargin.setLayoutParams(lp);
            } else if (add) {
              // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
              // actionBar.addTab(actionBar.newTab().setText("Utenti
              // ChipChat").setTabListener(tabListener));
              // actionBar.addTab(actionBar.newTab().setText("Altri
              // Utenti").setTabListener(tabListener));
              Log.i(TAG, "addTab");
              add = false;
              lp.setMargins(0, 0, 0, 0);
              Fmargin.setLayoutParams(lp);
            }
          }
        });
    if (getIntent().getStringExtra("Destinatario") != null) {
      MyListFragment.contatti = false;
      mSlidingLayout.closePane();
      FragmentManager fragmentManager = getSupportFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
      DetailFragment fragment = new DetailFragment();
      fragmentTransaction.replace(R.id.content_pane, fragment);
      fragmentTransaction.commit();
      DetailFragment.destinatario = getIntent().getStringExtra("Destinatario");
      DetailFragment.animato = getIntent().getBooleanExtra("Animato", true);
    } else mSlidingLayout.openPane();
    /*findViewById(R.id.chat_content).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mSlidingLayout.closePane();
        }
    });*/
  }