2013-10-04 46 views
1

我想使视图的屏幕可以使用视图寻呼机,向左或向右滑动,并使用滑动抽屉使底部的工具栏,但我的代码无法正常工作。这是XML。我怎样才能解决这个问题?如何在查看传呼机上使用滑动抽屉?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/LinearLayout01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:gravity="bottom" 
android:background="#ffffff"> 

<android.support.v4.view.ViewPager 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/viewPager" /> 

<SlidingDrawer 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/SlidingDrawer" 
    android:handle="@+id/slideButton" 
    android:content="@+id/contentLayout" 
    android:padding="10dip" 
    android:orientation="vertical" 
    android:layout_below="@+id/viewPager"> 

     <Button android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/slideButton" 
      android:background="@drawable/closearrow"> 
     </Button> 
     <LinearLayout 
      android:layout_width="wrap_content" 
      android:id="@+id/contentLayout" 
      android:orientation="vertical" 
      android:gravity="center" 
      android:padding="10dip" 
      android:background="#000000" 
      android:layout_height="wrap_content"> 
     <Button 
      android:id="@+id/Button01" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#FFFFE0" 
      android:layout_margin="2dp" 
      android:text="Option1"> 
     </Button> 
     <Button 
      android:id="@+id/Button02" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#FFFFE0" 
      android:layout_margin="2dp" 
      android:text="Option2"></Button> 
     <Button android:id="@+id/Button03" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:background="#FFFFE0" 
      android:text="Option3"> 
     </Button> 
     <Button android:id="@+id/Button04" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="2dp" 
      android:background="#FFFFE0" 
      android:text="Option4"> 
     </Button> 
    </LinearLayout> 
</SlidingDrawer> 

</RelativeLayout> 

回答

0

解决它: 的main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@color/white" 
android:orientation="vertical" > 
<!-- ViewPager --> 
<android.support.v4.view.ViewPager 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
android:id="@+id/viewPager" /> 
<!-- Footer --> 
<include layout="@layout/footer" /> 
</FrameLayout> 

footer.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:id="@+id/LinearLayout01" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@android:color/transparent" 
android:layout_gravity="bottom" 
android:orientation="vertical" > 

<SlidingDrawer 
    android:layout_width="100dp" 
    android:id="@+id/SlidingDrawer" 
    android:handle="@+id/slideHandleButton" 
    android:content="@+id/contentLayout" 
    android:padding="10dip" 
    android:layout_height="100dip" 
    android:orientation="horizontal" 
    android:layout_gravity="right"> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/slideHandleButton" 
     android:background="@drawable/closearrow"></Button> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:id="@+id/contentLayout" 
     android:orientation="vertical" 
     android:gravity="center|top" 
     android:padding="10dip" 
     android:background="#C0C0C0" 
     android:layout_height="wrap_content"> 


    <Button 
     android:id="@+id/btn1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Content"></Button> 

    <Button 
     android:id="@+id/btn2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Content"></Button> 

    <Button 
     android:id="@+id/Button03" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Content"></Button> 
      </LinearLayout> 
</SlidingDrawer> 
</LinearLayout> 
0

下面是一个使用ViewpPagerPagerTitleStripDrawerLayout

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:context=".MainActivity" > 

     <android.support.v4.view.PagerTitleStrip 
      android:id="@+id/pager_title_strip" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top" 
      android:background="#33b5e5" 
      android:paddingBottom="4dp" 
      android:paddingTop="4dp" 
      android:textColor="#fff" /> 
     </android.support.v4.view.ViewPager> 

    <ListView android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" 
     android:background="#111"/> 

</android.support.v4.widget.DrawerLayout> 

我相信这是不是在你的榜样的工作,是DrawerLayout应该有2个孩子工作的例子,第一个是视图主要布局,第二个是抽屉本身的视图。注意我的例子如何适合这个限制。使用这种