Android - создание слайдера для слайда с левой стороны
Я применил "Скользящий ящик" в своем приложении, используя нижеуказанный формат 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>
но то, что я хочу, - это сдвинуть ящик слева направо (по горизонтали) вместо этого справа налево, как сделать слайдер для скольжения влево-вправо?
Поделитесь своей идеей/просмотром/мнением/вопросом со мной и поймайте меня из этой проблемы.
Thanx
Ответы
Ответ 1
Вот учебник по этому вопросу: ссылка
Кажется, что нет места для скользящего ящика, я не могу найти никаких атрибутов макета, предоставляемых sdk. Но, как и в предыдущем учебном пособии, вы можете написать собственный виджет с выдвижным ящиком и применить атрибуты макета для позиционирования слайдера/панели.
Вы можете проверить https://github.com/umano/AndroidSlidingUpPanel
Ответ 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"
для получения дополнительной информации, пожалуйста, обратитесь к этой ссылке.
Ответ 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>
![SlidingDrawer from left to right]()