如何在双方滑动抽屉相对彼此? [英] How to create sliding drawer in both sides opposite to one another?

查看:73
本文介绍了如何在双方滑动抽屉相对彼此?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经加入了code的工作从右至左滑动完美,但我想从左向右滑动也因此检查的布局和帮助我out.Here我所提到的适当布局从右到左,是有可能得到的滑块窗口两侧我的意思是左,右水平...

 < XML版本=1.0编码=UTF-8&GT?;
                    <的FrameLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
                          机器人:layout_width =FILL_PARENT
                            机器人:layout_height =FILL_PARENT>
              < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
                     机器人:layout_width =match_parent
       机器人:layout_height =match_parent
       机器人:背景=@可绘制/ BG
         机器人:方向=垂直>
       <按钮
        机器人:ID =@ + ID /船
        机器人:layout_width =186dp
        机器人:layout_height =23dp
        机器人:layout_marginTop =49dp
        机器人:背景=@可绘制/注册
        机器人:文本=航运计算器
        机器人:文字颜色=#FFFFFFFF
        机器人:layout_gravity =中心
        机器人:TEXTSTYLE =黑体/>

< / LinearLayout中>
< SlidingDrawer
  机器人:ID =@ + ID /抽屉
  机器人:layout_width =match_parent
     机器人:layout_height =match_parent
  机器人:方向=横向
  机器人:手柄=@ + ID /手柄
  机器人:CONTENT =@ + ID /内容>
  < ImageView的
   机器人:ID =@ + ID /手柄
   机器人:layout_width =WRAP_CONTENT
   机器人:layout_height =FILL_PARENT
   机器人:SRC =@可绘制/标签/>

  <的LinearLayout
      机器人:ID =@ + ID /内容
      机器人:layout_width =WRAP_CONTENT
      机器人:layout_height =FILL_PARENT
      机器人:背景=@可绘制/ slidimage
      机器人:方向=垂直
      机器人:填充=10dp>
 <的TextView
            机器人:ID =@ + ID / text1中
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =中心
            机器人:layout_marginTop =15dp
            机器人:layout_marginLeft =51dp
            机器人:文本=注册
            机器人:文字颜色=#000000
            机器人:TEXTSIZE =28dp
            机器人:TEXTSTYLE =黑体/>

  < / LinearLayout中>
 < / SlidingDrawer>
 < SlidingDrawer
  机器人:ID =@ + ID /抽屉
  机器人:layout_width =match_parent
     机器人:layout_height =match_parent
   机器人:手柄=@ + ID /句柄
  机器人:layout_gravity =左
  机器人:scrollX =100dp
  机器人:方向=横向
  机器人:CONTENT =@ + ID /内容>
  < ImageView的
   机器人:ID =@ + ID /句柄
   机器人:layout_width =WRAP_CONTENT
   机器人:layout_height =FILL_PARENT
    机器人:layout_gravity =左
   机器人:SRC =@可绘制/标签/>

  <的LinearLayout
      机器人:ID =@ + ID /内容
      机器人:layout_width =WRAP_CONTENT
      机器人:layout_height =FILL_PARENT
       机器人:layout_gravity =左
      机器人:背景=@可绘制/ slidimage
      机器人:方向=垂直
      机器人:填充=10dp>
 <的TextView
            机器人:ID =@ + ID / text1中
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =中心
            机器人:layout_marginTop =15dp
            机器人:layout_marginLeft =51dp
            机器人:文本=注册
            机器人:文字颜色=#000000
            机器人:TEXTSIZE =28dp
            机器人:TEXTSTYLE =黑体/>

            < / LinearLayout中>
 < / SlidingDrawer>

< /的FrameLayout>
 

解决方案

我在这里得到了答案静态的不完全可能创造滑动,和我们不能使用的Andr​​oid版本:旋转= 180,因为,因为它会显示错误,因为没有资源发现,我们必须programatically.it需要添加视图布局创建它。

在单面的情况下,其简单的使用插件只能无需任何views..But当你想在多个方向滑动都需要的意见。

 < SlidingDrawer
  机器人:ID =@ + ID /抽屉
  机器人:layout_width =match_parent
     机器人:layout_height =match_parent
  机器人:方向=横向
  机器人:手柄=@ + ID /手柄
  机器人:CONTENT =@ + ID /内容>
  < ImageView的
   机器人:ID =@ + ID /手柄
   机器人:layout_width =WRAP_CONTENT
   机器人:layout_height =FILL_PARENT
   机器人:SRC =@可绘制/标签/>

  <的LinearLayout
      机器人:ID =@ + ID /内容
      机器人:layout_width =WRAP_CONTENT
      机器人:layout_height =FILL_PARENT
      机器人:背景=@可绘制/ slidimage
      机器人:方向=垂直
      机器人:填充=10dp>
 <的TextView
            机器人:ID =@ + ID / text1中
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =中心
            机器人:layout_marginTop =15dp
            机器人:layout_marginLeft =51dp
            机器人:文本=注册
            机器人:文字颜色=#000000
            机器人:TEXTSIZE =28dp
            机器人:TEXTSTYLE =黑体/>

  < / LinearLayout中>
 < / SlidingDrawer>
 

activity.java:

  @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.slider);

}
 

I have added the code that working for right to left sliding perfectly but i want sliding from left to right also so check the layout and help me out.Here i have mentioned the layout properly for right to left ,Is it possible to get the Slider window in both sides i mean left and right horizontally...

     <?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">
              <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                     android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@drawable/bg"
         android:orientation="vertical" >
       <Button
        android:id="@+id/ship"
        android:layout_width="186dp"
        android:layout_height="23dp"
        android:layout_marginTop="49dp"
        android:background="@drawable/signup"
        android:text="Shipping Calculator"
        android:textColor="#ffffffff"
        android:layout_gravity="center"
        android:textStyle="bold" />

</LinearLayout>
<SlidingDrawer
  android:id="@+id/drawer"
  android:layout_width="match_parent"
     android:layout_height="match_parent"
  android:orientation="horizontal"
  android:handle="@+id/handle"
  android:content="@+id/content">
  <ImageView 
   android:id="@+id/handle"
   android:layout_width="wrap_content"
   android:layout_height="fill_parent" 
   android:src="@drawable/tag"/>

  <LinearLayout
      android:id="@+id/content"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:background="@drawable/slidimage"
      android:orientation="vertical"
      android:padding="10dp" >
 <TextView
            android:id="@+id/text1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="15dp"
            android:layout_marginLeft="51dp"
            android:text="SIGN-UP"
            android:textColor="#000000"
            android:textSize="28dp"
            android:textStyle="bold" />

  </LinearLayout>
 </SlidingDrawer>
 <SlidingDrawer
  android:id="@+id/drawers"
  android:layout_width="match_parent"
     android:layout_height="match_parent"
   android:handle="@+id/handles"
  android:layout_gravity="left"
  android:scrollX="100dp"
  android:orientation="horizontal"
  android:content="@+id/contents">
  <ImageView 
   android:id="@+id/handles"
   android:layout_width="wrap_content"
   android:layout_height="fill_parent" 
    android:layout_gravity="left"
   android:src="@drawable/tag"/>

  <LinearLayout
      android:id="@+id/contents"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
       android:layout_gravity="left"
      android:background="@drawable/slidimage"
      android:orientation="vertical"
      android:padding="10dp" >
 <TextView
            android:id="@+id/text1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="15dp"
            android:layout_marginLeft="51dp"
            android:text="SIGN-UP"
            android:textColor="#000000"
            android:textSize="28dp"
            android:textStyle="bold" />

            </LinearLayout>
 </SlidingDrawer> 

</FrameLayout>

解决方案

I got the answer here statically its not exactly possible to create sliding ,and we cant use android:rotation=180 ,as because it will display error as no resource found, We have to create it programatically.it needs to add view in layout.

In case of single side its simple by using widget only no need any views..But the views are needed when you want to slide in multiple direction.

<SlidingDrawer
  android:id="@+id/drawer"
  android:layout_width="match_parent"
     android:layout_height="match_parent"
  android:orientation="horizontal"
  android:handle="@+id/handle"
  android:content="@+id/content">
  <ImageView 
   android:id="@+id/handle"
   android:layout_width="wrap_content"
   android:layout_height="fill_parent" 
   android:src="@drawable/tag"/>

  <LinearLayout
      android:id="@+id/content"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:background="@drawable/slidimage"
      android:orientation="vertical"
      android:padding="10dp" >
 <TextView
            android:id="@+id/text1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="15dp"
            android:layout_marginLeft="51dp"
            android:text="SIGN-UP"
            android:textColor="#000000"
            android:textSize="28dp"
            android:textStyle="bold" />

  </LinearLayout>
 </SlidingDrawer>

activity.java:

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.slider);

}

这篇关于如何在双方滑动抽屉相对彼此?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆