如何使用标签和自定义视图将FrameLayout的子项带到顶部

时间:2013-04-19 11:58:13

标签: android android-framelayout

Framelayout包含Tabs(来自ActionBarSherlock)和一个自定义视图 - ArcMenu(类似'Path'应用程序的菜单)。我想将ArcMenu置于选项卡内容的顶部,但不知何故,它隐藏在tabcontent下面。

我尝试在父视图上设置bringChildToFront()。这是代码。

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.worklist_activity);
        context = getApplicationContext();

        ActionBar actionbar = getSupportActionBar();
        actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        Tab tab1 = actionbar.newTab().setText("My Requests");
        Tab tab2 = actionbar.newTab().setText("Approved Requests");

        tab1.setTabListener(new TabListener<MyRequestsFragment>(
                this, "tab1", MyRequestsFragment.class));

        tab2.setTabListener(new TabListener<ApprovedRequestsFragment>(
                this, "tab2", ApprovedRequestsFragment.class));

        actionbar.addTab(tab1);
        actionbar.addTab(tab2);


        com.capricorn.ArcMenu arcMenu = (com.capricorn.ArcMenu) findViewById(R.id.arc_menu);

        int[] ITEM_DRAWABLES = { R.drawable.temp_1, R.drawable.temp_2,
                R.drawable.temp_3 };
        final int itemCount = ITEM_DRAWABLES.length;
        for (int i = 0; i < itemCount; i++) {
            ImageView item = new ImageView(this);
            item.setImageResource(ITEM_DRAWABLES[i]);

            final int position = i;
            arcMenu.addItem(item, new OnClickListener() {

                @Override
                public void onClick(View v) {
                    Toast.makeText(context, "pos " + position,
                            Toast.LENGTH_SHORT).show();
                }
            });
        }

        ViewParent parent = arcMenu.getParent();
        ViewGroup vg = (ViewGroup) parent;
        System.out.println(((ViewGroup) parent).getChildCount());
        System.out.println(vg.getChildAt(0).toString() + "\n"
                + vg.getChildAt(1).toString());

    }

这是我的xml文件

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linear_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/app_background_color"
    android:orientation="vertical"
    android:tag="tagtag" >

    <TabHost
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/tabhost"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:foregroundGravity="bottom" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TabWidget
                android:id="@+id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:foregroundGravity="bottom"
                android:id="@+id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />
        </LinearLayout>
    </TabHost>


 <com.capricorn.ArcMenu
        android:id="@+id/arc_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />
</FrameLayout>

1 个答案:

答案 0 :(得分:0)

您可以通过调用setVisibility(View.Gone)来隐藏TabHost视图 你可以通过在ArcMenu视图上调用bringToFront()来重新排序z-index