使用tooleap时将标签导航移至底部

时间:2016-03-23 17:25:57

标签: android android-fragments android-studio android-tabs tooleap

我在tooleap popout中添加了选项卡导航,但由于tooleap的工作方式,选项卡覆盖了工具栏,这是使用tooleap所必需的。我想将标签移动到屏幕底部以避免此问题。

目前的情况如下: Tooleap tabs

这是希望我希望它看起来像: bottom tabs

这是我想要标签的Tooleap活动:

    import android.os.Bundle;
    import com.tooleap.sdk.TooleapActivities;
    import android.support.v7.app.ActionBar;
    import android.support.v7.app.ActionBar.Tab;
    import android.util.Log;

    public class MyTooleapActivity extends  TooleapActivities.ActionBarActivity {

        private static final String TAG = "junk";

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_container);
            setUpTabs(savedInstanceState);
        }

        @Override
        protected void onSaveInstanceState(Bundle outState) {
            super.onSaveInstanceState(outState);
            //            save the selected tab's index so it's re-selected on orientation change
            outState.putInt("tabIndex", getSupportActionBar().getSelectedNavigationIndex());
        }

        private void setUpTabs(Bundle savedInstanceState) {

            ActionBar actionBar = getSupportActionBar();
            actionBar.setNavigationMode(actionBar.NAVIGATION_MODE_TABS);
            actionBar.setDisplayShowTitleEnabled(false);

            Tab tab_one = actionBar.newTab();
            Tab tab_two = actionBar.newTab();
            Tab tab_three = actionBar.newTab();

            FirstFragment firstFragment = new FirstFragment();
            tab_one.setText("One")
                    .setContentDescription("The first tab")
                    .setTabListener(
                            new MyTabListener<FirstFragment>(
                                    firstFragment));

            SecondFragment secondFragment = new SecondFragment();
            tab_two.setText("Two")
                    .setContentDescription("The second tab")
                    .setTabListener(
                            new MyTabListener<SecondFragment>(
                                    secondFragment));

            ThirdFragment thirdFragment = new ThirdFragment();
            tab_three
                    .setText("Three")
                    .setContentDescription("The third tab")
                    .setTabListener(
                            new MyTabListener<ThirdFragment>(
                                    thirdFragment));

            actionBar.addTab(tab_one);
            actionBar.addTab(tab_two);
            actionBar.addTab(tab_three);

            if (savedInstanceState != null) {
                Log.i(TAG, "setting selected tab from saved bundle");
//            get the saved selected tab's index and set that tab as selected
                actionBar.setSelectedNavigationItem(savedInstanceState.getInt("tabIndex", 0));
            }
        }

    }

这是我的activity_container.xml:

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </FrameLayout>
</LinearLayout>
根据要求

Manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MyActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MyTooleapActivity"
            android:launchMode="singleInstance"
            android:taskAffinity=".tooleap"
            android:theme="@style/Theme.AppCompat.Translucent">
            <intent-filter>
                <action android:name="com.tooleap.sdk.TOOLEAP_SHOW" />
            </intent-filter>
        </activity>

        <service android:name="com.tooleap.sdk.TooleapAppService" />
        <service
            android:name="com.tooleap.sdk.TooleapUIService"
            android:exported="true"
            android:process=":UIService">
            <intent-filter>
                <action android:name="com.tooleap.sdk.BIND_UI_SERVICE" />
            </intent-filter>
        </service>

        <receiver android:name="com.tooleap.sdk.TooleapReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REPLACED" />

                <data android:scheme="package" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.tooleap.sdk.TOOLEAP_ACTION" />
            </intent-filter>
        </receiver>

        <meta-data
            android:name="com.tooleap.sdk.apiKey"
            android:value="Placeholder" />

        <activity android:name=".UserBuilding"></activity>
    </application>

</manifest>

0 个答案:

没有答案