6

グーグルがこれを「リボンメニュー」と呼んでいるところをどこかで読んだ。

とにかく、これは私が意味することです(このブログも見てください):

リボンメニュー

これはGoogle+アプリです。アクションバーのG+アイコンをクリックすると、画面全体が右に移動し、メニューが表示されます。ActionBarも移動することに注意してください。

アプリケーションでこれを実行したいのですが、方法がわかりません。アニメーションフレームワークの基本的な知識があります。

質問は次のとおりです。

  • どのようなレイアウトを使用する必要がありますか?
  • 画面全体を(アクションバーを使用して)アニメーション化するにはどうすればよいですか?

これらがあまり一般的な質問ではないことを願っています。例を求めています。前もって感謝します。

4

3 に答える 3

3

はい、分かりました。簡単だ。

getWindow().getDecorView();

この行はあなたの活動のメインビューを提供します。メインビューには、アクティビティに表示されるすべてのものが含まれています。次に、それをアニメートできます。答えは簡単でした。

このリンクは私を大いに助けました:http ://android.cyrilmottier.com/?p = 658

編集:

これは先に進む方法ではありません。Cyril Mottierが言ったように、それはハックであり、私は多くの問題を見つけました。すべてをやり直して、今は自分のActionBarを実装しています。

于 2012-07-16T11:35:21.490 に答える
1

私もこれを探していました。同じものの別名はスライドアウトナビゲーションです。これが私がGithubで見つけた解決策です:

https://github.com/jfeinstein10/SlidingMenu

https://github.com/korovyansk/android-fb-like-slideout-navigation

https://github.com/darvds/RibbonMenu

https://github.com/Gregadeaux/android-fly-in-app-navigation

于 2012-07-27T20:57:51.820 に答える
0

あなたはナビゲーションドロワーによってこれを非常にうまく行うことができます、これは私がそれを見つけたサンプルです

MainActivity.java

package ir.ZiaNazari.navigationdrawer;

import android.os.Bundle;
import android.app.Activity;
import android.content.res.Configuration;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

private String[] drawerListViewItems;
private DrawerLayout drawerLayout;
private ListView drawerListView;
private ActionBarDrawerToggle actionBarDrawerToggle;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // get list items from strings.xml
    drawerListViewItems = getResources().getStringArray(R.array.items);

    // get ListView defined in activity_main.xml
    drawerListView = (ListView) findViewById(R.id.left_drawer);

    // Set the adapter for the list view
    drawerListView.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_listview_item, drawerListViewItems));

    // 2. App Icon
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    // 2.1 create ActionBarDrawerToggle
    actionBarDrawerToggle = new ActionBarDrawerToggle(
            this,                  /* host Activity */
            drawerLayout,         /* DrawerLayout object */
            R.drawable.ic_launcher,  /* nav drawer icon to replace 'Up' caret */
            R.string.drawer_open,  /* "open drawer" description */
            R.string.drawer_close  /* "close drawer" description */
            );

    // 2.2 Set actionBarDrawerToggle as the DrawerListener
    drawerLayout.setDrawerListener(actionBarDrawerToggle);

    // 2.3 enable and show "up" arrow
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // just styling option
    drawerLayout.setDrawerShadow(R.drawable.ic_launcher, GravityCompat.START);

    drawerListView.setOnItemClickListener(new DrawerItemClickListener());
}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    // Sync the toggle state after onRestoreInstanceState has occurred.
     actionBarDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    actionBarDrawerToggle.onConfigurationChanged(newConfig);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

     // call ActionBarDrawerToggle.onOptionsItemSelected(), if it returns true
    // then it has handled the app icon touch event

    if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

private class DrawerItemClickListener implements ListView.OnItemClickListener {
    @Override
    public void onItemClick(AdapterView parent, View view, int position, long id) {
        Toast.makeText(MainActivity.this, ((TextView)view).getText(), Toast.LENGTH_LONG).show();
        drawerLayout.closeDrawer(drawerListView);

    }
}
}

drawer_listview_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@android:id/text1"
    android:textColor="#fff"
    android:textSize="20sp"
    android:gravity="center_vertical"
    android:paddingStart="14.5sp"
    android:paddingEnd="14.5sp"
    android:minHeight="35sp" >
</TextView>

activity_main.xml

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/myshape"
    >

    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- The navigation drawer -->
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="#666"
        android:dividerHeight="1dp"
        android:background="#333"
        android:paddingLeft="15sp"
        android:paddingRight="15sp"
        />

</android.support.v4.widget.DrawerLayout>

string.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Navigation Drawer</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string> 
    <string-array name="items">
        <item>Item 1</item>
        <item>Item 2</item>
        <item>Item 3</item>
        <item>Item 4</item>
        <item>Item 5</item>
        <item>Item 6</item>
    </string-array> 
    <string name="drawer_open">Open navigation drawer</string>
    <string name="drawer_close">Close navigation drawer</string>

</resources>

これがあなたや他の人に役立つことを願っています

于 2013-11-06T05:43:21.833 に答える