【问题标题】:Android - Making Sliding Drawer to slide from Left-to-RightAndroid - 使滑动抽屉从左向右滑动
【发布时间】:2011-04-17 03:08:17
【问题描述】:

我使用以下 XML 布局在我的应用程序中实现了“滑动抽屉”: (我从 androidpeople.com 得到这个例子)

<LinearLayout android:id="@+id/LinearLayout01"
 android:layout_width="fill_parent" android:layout_height="fill_parent"
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:background="@drawable/androidpeople">

 <SlidingDrawer 
  android:layout_width="wrap_content" 
  android:id="@+id/SlidingDrawer" 
  android:handle="@+id/slideHandleButton" 
  android:content="@+id/contentLayout" 
  android:layout_height="75dip"
  android:orientation="horizontal">

  <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="horizontal" 
   android:gravity="center|top" 
   android:padding="10dip" 
   android:background="#C0C0C0" 
   android:layout_height="wrap_content">


   <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Content"></Button>
   <Button android:id="@+id/Button02" 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>

但我想要的是从左到右(水平)而不是从右到左滑动抽屉,我如何使滑动抽屉从左到右方向滑动?

请与我分享您的想法/观点/意见/问题,让我摆脱这个问题。

【问题讨论】:

标签: android android-widget android-sliding


【解决方案1】:

这里有一个教程:link

滑动抽屉好像没有定位,找不到sdk提供的布局属性。但就像在上面的教程中一样,您可以编写自己的滑动抽屉小部件并应用布局属性来定位滑块/面板。


您可以结帐https://github.com/umano/AndroidSlidingUpPanel

【讨论】:

  • 我已经查看了那个链接,在这个链接中我没有找到答案中给出的那个链接上的任何项目/代码,而且我也没有找到任何关于“水平滑块”的信息
  • 您的问题解决了吗?写你自己的课,也许扩展滑动抽屉,会解决它
  • 我相信除非您扩展小部件,否则不支持此功能
  • thanx,但我不知道该怎么做?请通过更新您当前的答案分享您关于从左到右扩展和滑动的知识,请
  • 尝试在此处添加答案的主要内容,而不是仅仅依赖链接,因为它们可能会死掉并且您无法将听众附加到他们的生活中。
【解决方案2】:

您可以将它用于从左到右的抽屉..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView 
android:layout_width="50dip"
android:layout_height="50dip"
android:text="@string/hello"
/>
<SlidingDrawer
 android:id="@+id/drawer"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal"
 android:handle="@+id/handle"     
 android:content="@+id/content">


<ImageView
 android:id="@id/handle"
 android:layout_width="50dip"
 android:layout_height="50dip"  
 android:src="@drawable/icon"
/>

<LinearLayout
 android:id="@id/content"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical">
<Button
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:text="Big Big Button"/>
</LinearLayout>

</SlidingDrawer>
</LinearLayout>

【讨论】:

    【解决方案3】:

    最好和简单的解决方案是向 SlidingDrawer 添加一行代码,android:rotation = "180" 更多信息请参考this link

    【讨论】:

    • 它不能在所有设备上工作,你能告诉我,什么问题。虽然它在三星平板电脑上工作。
    • SlideDrawer 中的所有视图都是反相器,非常糟糕
    • 奇思妙想却没拉开抽屉只拉取回
    【解决方案4】:

    最好的答案是使用 sephiroth 基于原始 SlidingDrawer 编写的组件: http://blog.sephiroth.it/2011/03/29/widget-slidingdrawer-top-to-bottom/

    【讨论】:

      【解决方案5】:

      我使用了 Girish R 的答案并只是旋转了它.... 就像一个魅力 另外,我使用了框架布局来确保它正确打开....

      <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
      
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          >
          <SlidingDrawer
              android:id="@+id/drawer"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"
              android:handle="@+id/handle"
              android:rotation="180"
              android:content="@+id/content">
      
      
              <ImageView
                  android:id="@id/handle"
                  android:layout_width="50dip"
                  android:layout_height="50dip"
                  android:src="@drawable/ic_launcher"
                  android:rotation="180"
                  />
      
              <LinearLayout
                  android:id="@id/content"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:orientation="vertical"
                  android:rotation="180">
                  <Button
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:text="Big Big Button"/>
              </LinearLayout>
          </SlidingDrawer>
          <TextView
              android:layout_width="50dip"
              android:layout_height="50dip"
              android:text="HELLO WORLD"
              />
      
      </FrameLayout>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-10
        相关资源
        最近更新 更多