Tabs without icon
Asked Answered
D

5

13

I'm having a look at the "Tab Layout" tutorial which is perfectly clear and my question is very simple : is it possible to create tabs with no icon, just a single title?

Derose answered 16/12, 2010 at 12:35 Comment(0)
N
13

is it possible to create tabs with no icon, just a single title?

Yes. If you are doing something like:

spec = tabHost.newTabSpec("tab_name").setIndicator("Some tab",
                      res.getDrawable(R.drawable.ic_tab_artists))
                  .setContent(intent);

Change it to:

spec = tabHost.newTabSpec("tab_name").setIndicator("Some tab").setContent(intent);
Northernmost answered 16/12, 2010 at 13:4 Comment(0)
A
3

I guess you are reading Tab layout tutorial There you can see that they use following function to set title and icon:

setIndicator("Albums",res.getDrawable(R.drawable.ic_tab_albums))

Same function has another version, which does not take drawable as parameter

.setIndicator("Albums")

So, this second version of the function creates tab without icon. Simple answer - yes, you can create tabs with title only.

Aran answered 16/12, 2010 at 13:10 Comment(0)
L
2

You can set a fixed height of the tabwidged.

In the Code:

tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=n;

Or in the XML: ..

android:layout_height="n"

.. (with android:gravity you can affect where ur tabwidget gets cut)

Longing answered 13/4, 2011 at 13:32 Comment(0)
P
1

You can use TabSpec.setIndicator(View view) method to customize your indicator, this method was introduced since API level 4.

Phoebephoebus answered 30/5, 2011 at 14:20 Comment(0)
J
0
 TabSpec laboratorySpec = tabHost.newTabSpec("Laboratory");
 laboratorySpec.setIndicator("Laboratory");
 Intent laboratoryIntent = new Intent(this, LaboratoryActivity.class);
 laboratorySpec.setContent(laboratoryIntent);

worked for me

Joses answered 19/6, 2013 at 8:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.