Android - изготовление скользящего ящика для скольжения слева направо
-
05-10-2019 - |
Вопрос
Я реализовал «скользящий ящик» в моем приложении, используя ниже показаний 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>
Но то, что я хочу, чтобы скользить ящик из левой справа (горизонтальный) вместо этого прямо влево, как я могу сделать скользящий ящик для скольжения из левого направого направления?
Пожалуйста, поделитесь своей идеей / видом / мнением / проблемой со мной и поймай меня из этой проблемы.
Решение
Вот учебник по этому вопросу: связь
Похоже, что нет позиционирования для скользящего ящика, я не могу найти никаких атрибутов макета, предоставляемых SDK. Но, как в руководстве выше, вы можете написать свой собственный виджет скользящего ящика и примените атрибуты макета для позиционирования слайдера / панели.
Вы можете оформить заказ https://github.com/umano/andlroidslidingupppanel.
Другие советы
Вы можете использовать это для левого вправо.
<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>
Лучшее и простое решение добавляют одну строку кода в SlidingDrawer, android:rotation = "180"
Для получения дополнительной информации, пожалуйста, обратитесь к эта ссылка.
Лучший ответ - использовать этот компонент, который Sephiroth написал на основе оригинального скользящего обслуживания:http://blog.sephirothh.it/2011/03/29/widget-slingdrawer-top-to-bottom/
Я использовал ответ 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>