a SlidingMenu lib like facebook and gmail
package com.example.androidtest;import android.annotation.SuppressLint;import android.app.FragmentTransaction;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import com.example.fragment.ContentFragment;import com.example.fragment.MenuFragment;import com.slidingmenu.lib.SlidingMenu;import com.slidingmenu.lib.app.SlidingActivity;@SuppressLint("NewApi")public class MainActivity extends SlidingActivity { public FragmentTransaction fraTra = null; public MenuFragment menuFra = null; public ContentFragment contentFra = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setBehindContentView(R.layout.menu_layout); // 设置菜单页 fraTra = this.getFragmentManager().beginTransaction(); menuFra = new MenuFragment(this); contentFra = new ContentFragment("I'm John"); fraTra.replace(R.id.menu_fl, menuFra); fraTra.replace(R.id.main_rl, contentFra); fraTra.commit(); // SlidingMenu sm = getSlidingMenu(); //滑动菜单 sm.setShadowWidth(15); // 阴影宽度 sm.setBehindOffset(300); // 菜单与边框的距离 sm.setShadowDrawable(R.drawable.shadow); // 滑动菜单渐变 sm.setFadeDegree(0.35f); //色度 sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); // 边缘滑动菜单 // getActionBar().setDisplayHomeAsUpEnabled(true); //ActionBar(左上角)是否可以点击 } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: //判断是菜单打开还是关闭 toggle(); return true; } return super.onOptionsItemSelected(item); }}
https://github.com/jfeinstein10/SlidingMenu
...You must Sign up as a member of Effecthub to view the content.
Latest Posts
- Android: CookieManager removeAllCookie() Crash
- XlistView: A listview which can pull to refresh and load more (1)
- Millions of Android Phones Could Be Affected by the Heartbleed Bug. Check to See if Yours Is One of Them
- TOP 10 ANDROID GAMES FOR MARCH 2014
- Android:Button with different textcolor and background in different states
2640 views 1 comments
You must Sign up as a member of Effecthub to join the conversation.