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?
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);
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.
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)
You can use TabSpec.setIndicator(View view)
method to customize your indicator, this method was introduced since API level 4.
TabSpec laboratorySpec = tabHost.newTabSpec("Laboratory");
laboratorySpec.setIndicator("Laboratory");
Intent laboratoryIntent = new Intent(this, LaboratoryActivity.class);
laboratorySpec.setContent(laboratoryIntent);
worked for me
© 2022 - 2024 — McMap. All rights reserved.