Set Actionbar Tabs at Bottom in Actionbaractivity

Cannot create tabs in action bar using ActionBarActivity

Do not use ActionBarActivity since it is deprecated.

And you are using:

Theme.AppCompat.Light.DarkActionBar

with : ActionBarActivity

Change it to AppCompatActivity in your java codes(Activity).

This should solve the problem. and of course if you are using AppCompat:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarmain);
setSupportActionBar(toolbar);

similiar questions:

Android getActionBar vs getSupportActionBar?

put tabs in the bottom of screen

These sample xml code defines move tab to bottom of the screen:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@android:id/tabs" >

<FrameLayout
android:id="@+id/tab_home"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

<FrameLayout
android:id="@+id/tab_video"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

<FrameLayout
android:id="@+id/tab_audio"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>

<FrameLayout
android:id="@+id/tab_blog"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>

<FrameLayout
android:id="@+id/tab_gal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>

<FrameLayout
android:id="@+id/tab_more"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</FrameLayout>

<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" //align parent bottom mainly used for move the tab to bottom of the screen.
android:background="@drawable/ic_launcher"
android:divider="@null" />

<!-- android:background="#d8e49c" -->
</RelativeLayout>
</TabHost>

</LinearLayout>

Android studio actionBar with Tabs

So I ran the project myself. Theme.AppCompat only generates an ActionBar if your base activity is from ActionBarActivity. Use @android:style/Theme.Holo.Light.DarkActionBar instead of Theme.AppCompat in your styles.xml to generate an action bar by default.

The error is caused by attempting to call ActionBar methods when getActionBar() was returning null. The tutorial you linked does not show the styles.xml (and is also a very outdated tutorial!)

Android Studio - Sliding Tabs appear below action bar instead of on action bar

To answer my own question, it will take a few steps to achieve this. First you need to create your own custom action bar in an seperate XML file. Then you need to apply a "NoActionBar" Theme to the activity that you want to put the action bar with silding tabs in. Then you need to write in Java that you want to set the action bar in that particular activity to your own custom action bar. Then I believe, don't quote me, you need to add the sliding tabs in the action bar layout file along with the view pager.

Obviously there are a lot of steps and it is very hard to explain them in this way. SlideNerd has a superb set of video tutorials on how to do this in case you're a visual learner.

CustomActionBar Tutorial (Videos 3-5): https://www.youtube.com/watch?v=pMO8EVkhJO8&index=3&list=PLonJJ3BVjZW6CtAMbJz1XD8ELUs1KXaTD

SlidingTabLayout Tutorial (Videos 26-28): https://www.youtube.com/watch?v=Fl0xMuo10yA&index=26&list=PLonJJ3BVjZW6CtAMbJz1XD8ELUs1KXaTD

How to make Android show Tabs at the bottom of screen

I would imagine you want to make your Android app look more like an iOS device. As Pozzo Apps said, I would highly advise you to not do this, as it goes strictly against the Android Design Guidelines.

If you feel that you absolutely have to and there is absolutely no other possible way of redesigning your app, then you can use this answer to help you.



Related Topics



Leave a reply



Submit