我已经看到一些关于这个的喋喋不休,但没有什么明确的.有没有办法将TabWidget中的标签放到屏幕底部?如果是这样,怎么样?
我尝试了以下,但没有奏效:
a)在tablayout下面设置tabwidget
b)将tabwidget的引力设置为"bottom"
谢谢!llappall
我想在屏幕的底部放置标签.为此,我有以下代码:
package info.androidhive.tabsswipe;
import info.androidhive.tabsswipe.adapter.TabsPagerAdapter;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {
private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "Top Rated", "Games", "Movies" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter) ;
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
// Adding Tabs
for (String tab_name : …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序,它使用从互联网上下载的Tab Host图标,图标大小为30x30.
for(int i = 0; i < titleNames.size(); i++)
{
intent = new Intent().setClass(context, Gallery.class);
sp = tabHost.newTabSpec(titleNames.get(i)).setIndicator(titleNames.get(i), res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(sp);
}
Run Code Online (Sandbox Code Playgroud)
如果我使用上面的代码(来自资源的图标)来设置指示器文本和图标,它运行良好,图标适合选项卡小部件.
for(int i = 0; i < titleNames.size(); i++)
{
intent = new Intent().setClass(context, Gallery.class);
sp = tabHost.newTabSpec(titleNames.get(i)).setIndicator(titleNames.get(i), Drawable.createFromPath(path+iconNames.get(i))).setContent(intent);
tabHost.addTab(sp);
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用此代码(从互联网及其内部存储器下载的图像)而不是之前的代码,图标看起来很小,甚至两个图标的高度和宽度值都相同.从互联网下载时我不会缩放图标,我将它们保存为PNG.任何人都知道问题是什么?
解:
现在我使用下面的代码,而不是使用我以前的代码向对象主机添加对象,它运行得很好.这两者之间的区别是新的一个是使用一个布局,其中有图像视图和文本视图来指示图标和下面的文本来设置意图的指示.因此,通过这种方式,我可以从图像视图调用方法,使图像适合xml文件中定义的边界.以下是使用View执行此操作的方法.
private void addTab(String labelId, Drawable drawable, Class<?> c) {
tabHost = getTabHost();
intent = new Intent(this, c);
spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) …Run Code Online (Sandbox Code Playgroud) 我正在查看http://bakhtiyor.com/2009/10/iphonish-tabs/上发布的示例,实际上他们已将Radio按钮替换为Tabview.
但问题是,我无法将图像设置为中心.它始终与左对齐.
这是截图.我希望我的视图看起来像这样,但我希望图像在中心.

这就是我的布局XML文件的外观
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dip"/>
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:checkedButton="@+id/allcontacts"
android:gravity="center"
android:id="@+id/contactgroup">
<RadioButton android:id="@+id/allcontacts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:background="@drawable/button_radio"/>
<RadioButton
android:id="@+id/categories"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_radio"
android:orientation="vertical"
android:layout_gravity="center|right"/>
<RadioButton android:id="@+id/favourites"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_weight="1"
android:background="@drawable/button_radio"/>
</RadioGroup>
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" android:visibility="gone" />
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
请指教
使用"默认"选项卡小部件后更新的图像

是否可以在默认的tabview中自定义上面的单选按钮.
我想为我的Android应用程序制作自定义tabbar,如pic(iphone上的tabbar)

当我从标签传递给其他人时,它会制作动画
请帮忙