当前位置:   article > 正文

Android UI-SlidingMenu侧滑菜单效果(1),Activity的6大难点你会几个_android slidingmenu缩放功能

android slidingmenu缩放功能

sm.setShadowDrawable(null);

// 设置滑动菜单视图的宽度

sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);

// 设置渐入渐出效果的值

sm.setFadeDegree(0.35f);

// 设置触摸屏幕的模式,这里设置为全屏

sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

// 设置下方视图的在滚动时的缩放比例

sm.setBehindScrollScale(0.0f);

}

@Override

protected void onSaveInstanceState(Bundle outState) {

super.onSaveInstanceState(outState);

getSupportFragmentManager().putFragment(outState, “mContent”, mContent);

}

/**

  • 切换Fragment

  • @param fragment

*/

public void switchConent(Fragment fragment, String title) {

mContent = fragment;

getSupportFragmentManager().beginTransaction()

.replace(R.id.content_frame, fragment).commit();

getSlidingMenu().showContent();

topTextView.setText(title);

}

@Override

public void onClick(View v) {

switch (v.getId()) {

case R.id.topButton:

toggle();

break;

default:

break;

}

}

}

侧边栏菜单Fragment

package com.infzm.slidingmenu.demo.fragment;

import android.app.Activity;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.ViewGroup;

import com.infzm.slidingmenu.demo.MainActivity;

import com.infzm.slidingmenu.demo.R;

/**

  • @date 2014/11/14

  • @author wuwenjie

  • @description 侧边栏菜单

*/

public class LeftFragment extends Fragment implements
OnClickListener{

private View todayView;

private View lastListView;

private View discussView;

private View favoritesView;

private View commentsView;

private View settingsView;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

}

@Override

public void onAttach(Activity activity) {

super.onAttach(activity);

}

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.layout_menu, null);

findViews(view);

return view;

}

public void findViews(View view) {

todayView = view.findViewById(R.id.tvToday);

lastListView = view.findViewById(R.id.tvLastlist);

discussView = view.findViewById(R.id.tvDiscussMeeting);

favoritesView = view.findViewById(R.id.tvMyFavorites);

commentsView = view.findViewById(R.id.tvMyComments);

settingsView = view.findViewById(R.id.tvMySettings);

todayView.setOnClickListener(this);

lastListView.setOnClickListener(this);

discussView.setOnClickListener(this);

favoritesView.setOnClickListener(this);

commentsView.setOnClickListener(this);

settingsView.setOnClickListener(this);

}

@Override

public void onDestroyView() {

super.onDestroyView();

}

@Override

public void onDestroy() {

super.onDestroy();

}

@Override

public void onClick(View v) {

Fragment newContent = null;

String title = null;

switch (v.getId()) {

case R.id.tvToday: // 今日

newContent = new TodayFragment();

title = getString(R.string.today);

break;

case R.id.tvLastlist:// 往期列表

newContent = new LastListFragment();

title = getString(R.string.lastList);

break;

case R.id.tvDiscussMeeting: // 讨论集会

newContent = new DiscussFragment();

title = getString(R.string.discussMeetting);

break;

case R.id.tvMyFavorites: // 我的收藏

newContent = new MyFavoritesFragment();

title = getString(R.string.myFavorities);

break;

case R.id.tvMyComments: // 我的评论

newContent = new MyCommentsFragment();

title = getString(R.string.myComments);

break;

case R.id.tvMySettings: // 设置

newContent = new MySettingsFragment();

title = getString(R.string.settings);

break;

default:

break;

}

if (newContent != null) {

case R.id.tvMyComments: // 我的评论

newContent = new MyCommentsFragment();

title = getString(R.string.myComments);

break;

case R.id.tvMySettings: // 设置

newContent = new MySettingsFragment();

title = getString(R.string.settings);

break;

default:

break;

}

if (newContent != null) {

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/574578
推荐阅读
相关标签
  

闽ICP备14008679号