質問

私はを使用しています slidingDrawer 私のアプリケーションでは、ポートレートモードのときにハンドラーが下部に配置されます。ユーザーが横向きモード (ワイドスクリーン) に切り替えたとき、ハンドラーを左側に配置したいと思います。向きを縦から横に変更すると、ハンドラーが右側に配置されます。

レイアウト XML を次のように定義しました。

<SlidingDrawer
    android:id="@+id/l_drawer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:handle="@+id/l_handle"
    android:content="@+id/l_content"
    android:orientation="horizontal"
    android:layout_gravity="left"
    >

左から右にスライドさせる方法を知っている人はいますか?

役に立ちましたか?

解決

私は多分、SlidingDrawerのソースコードをつかんで、それを変更すると、変更したバージョンを使用する以外、あなたができるとは思いません。あなたは同様に、上から下降SlidingDrawerをすることはできません。

他のヒント

それを行う簡単な方法を見つけました。あなたがしなければならないのは、slidingDrawer、コンテンツ、ハンドルの 180 度の回転を設定することだけです。私がやったように、上から降りてくる SlidingDrawer も同様に作成できます。 ここ.

ここでの例を右から左に見て、違いを確認してください。

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slidingDrawer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_horizontal"
    android:handle="@+id/handle"
    android:content="@+id/content">
    <ImageView android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />
    <ImageView android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:src="@drawable/ic_launcher" />
</SlidingDrawer>

左からスライドさせるために変更した内容を見てください。

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slidingDrawer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_horizontal"
    android:handle="@+id/handle"
    android:content="@+id/content"
    android:rotation="180">
    <LinearLayout android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageView android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            android:rotation="180" />
    </LinearLayout>
    <ImageView android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:src="@drawable/ic_launcher"
        android:rotation="180" />
</SlidingDrawer>

ハンドルとして設定する LinearLayout も作成し、その回転は変更しませんでしたが、その子の回転は変更したことに注意してください。これは私が抱えていた小さな問題を防ぐためでしたが、すべてが正常に動作しており、簡単です。

私はそれにクラスを書き換え、それ私のオープンソースライブラリの一部で行われてきました。それは右のそれを得るために一週間、ほとんど連れて行ってくれました。チェックしてください私の SlidingTray の中の Android用Aniqroid のオープンソースライブラリます。

http://aniqroid.sileria.com/doc/apiする

ダウンロードリンクとはリンクSlidingTrayクラスのドキュメントを検索します。

(情報開示:私はプロジェクトのメンテナ午前)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top