2014-10-30 86 views
-2

我想更改幻灯片菜单的背景滑动菜单在Android

看到下面!

enter image description here

我想黑颜色改变为其它颜色,但我不能帮助我,请我 代码是在这里

activity_main.xml中:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/bg_main" > 

<com.coboltforge.slidemenu.SlideMenu 
    android:id="@+id/slideMenu" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 


</com.coboltforge.slidemenu.SlideMenu> 

<TextView 
    android:id="@+id/textView1" 
    android:background="@drawable/bg_top" /> 

MainActivity.java:

import com.coboltforge.slidemenu.SlideMenu; 
import com.coboltforge.slidemenu.SlideMenu.SlideMenuItem; 
import com.coboltforge.slidemenu.SlideMenuInterface.OnSlideMenuItemClickListener; 

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.Toast; 

public class MainActivity extends Activity implements OnSlideMenuItemClickListener { 

    private SlideMenu slidemenu; 
    private final static int MYITEMID = 42; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.activity_main); 

     /* 
     * There are two ways to add the slide menu: 
     * From code or to inflate it from XML (then you have to declare it in the activities layout XML) 
     */ 
     // this is from code. no XML declaration necessary, but you won't get state restored after rotation. 
//  slidemenu = new SlideMenu(this, R.menu.slide, this, 333); 
     // this inflates the menu from XML. open/closed state will be restored after rotation, but you'll have to call init. 
     slidemenu = (SlideMenu) findViewById(R.id.slideMenu); 
     slidemenu.init(this, R.menu.slide, this, 333); 

     // this can set the menu to initially shown instead of hidden 
//  slidemenu.setAsShown(); 

     // set optional header image 
     slidemenu.setHeaderImage(R.drawable.headerbanner); 

     // this demonstrates how to dynamically add menu items 
     SlideMenuItem item = new SlideMenuItem(); 
     item.id = MYITEMID; 
     item.icon = getResources().getDrawable(R.drawable.ic_launcher); 
     item.label = "Dynamically added item"; 
     slidemenu.addMenuItem(item); 

     // connect the fallback button in case there is no ActionBar 
     Button b = (Button) findViewById(R.id.buttonMenu); 
     b.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       slidemenu.show(); 
      } 
     }); 
    }  
} 

这很简单,优雅:https://github.com/akotoe/android-slide-out-menu.git

+0

任何一个答案?? – user3142300 2014-11-05 06:01:51

回答

0

只需创建一个在您绘制文件夹的新文件名为“背景”,然后在你想 快速例如XML输入样式:

,然后引用这个在抽屉XML中的新文件像 android:background =“@ drawable/background”

希望有所帮助!