English 中文(简体)
如何使SlidingDrawer在展示时推导现有的布局?
原标题:How to make SlidingDrawer push existing layouts when showing?
  • 时间:2011-11-21 09:34:03
  •  标签:
  • android

Main purpose: I have a listview display on screen, and want to have a SlidingDrawer on the bottom of it.

I m实际对SlidingDrawer至ggle持“手法”的看法,以显示/ide化推器。

I want my bar to show by sliding in and "shrink" the listview layout. And when it hides to make the listview layout return to its original view.

现在,我有一份名单布局,该名单已经确定,并且拥有一个透明的持有人,供提人展示或藏匿。

谁能帮助我看不到这一点?

活动xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Container"
android:id="@+id/layout"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1" >

    <ListView
        android:id="@+id/listview"
        style="@style/Widget.ListView" />
</LinearLayout>

<include
    layout="@layout/delete_bar" />

</LinearLayout>

删除

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/MarginTopBottom"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="bottom"
    android:orientation="vertical"
    android:padding="10dp" >

    <my.WrappingSlidingDrawer
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:content="@+id/content"
        android:handle="@+id/handle" >

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <Button
                style="@style/Widget.Button.Wrap"
                android:id="@+id/btn_DeleteBar_delete"
                android:layout_weight="1"
                android:onClick="onClick"
                android:text="@string/w_Delete" />

            <Button
                style="@style/Widget.Button.Wrap"
                android:id="@+id/btn_DeleteBar_cancel"
                android:layout_weight="1"
                android:onClick="onClick"
                android:text="@string/w_Cancel" />
        </LinearLayout>

        <Button
            android:id="@+id/handle"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:visibility="gone" />
    </my.WrappingSlidingDrawer>
</LinearLayout>
问题回答

你们可能要检查这一答案(可能还有其他答案)。 看来他们正试图完成类似的工作。 - Android: Expansion/collapse animation

Try this with default drawer.

actionBarToggle = new ActionBarDrawerToggle(
            this,                  /* host Activity */
            mDrawerLayout,         /* DrawerLayout object */
            R.drawable.ic_drawer,  /* nav drawer image to replace  Up  caret */
            R.string.drawer_open,  /* "open drawer" description for accessibility */
            R.string.drawer_close  /* "close drawer" description for accessibility */
            ) {public void onDrawerSlide(View drawerView, float slideOffset)
        {
            float moveFactor = (mDrawerList.getWidth() * slideOffset);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) 
            {
                frameLayout.setTranslationX(moveFactor);
            }
            else
            {
                TranslateAnimation anim = new TranslateAnimation(lastTranslate, moveFactor, 0.0f, 0.0f);
                anim.setDuration(0);
                anim.setFillAfter(true);
                frameLayout.startAnimation(anim);

                lastTranslate = moveFactor;
            }

or use different library s for drawing drawer.

i 希望这将有助于消除这种状况。

<?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"
android:background="#FF4444CC">
<SlidingDrawer android:id="@+id/drawer" android:layout_width="fill_parent" android:layout_height="fill_parent" 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/tray_handle_normal"`/>

<Button android:id="@id/content" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="I m in here!" />

</SlidingDrawer> </FrameLayout>




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签