标签: tabwidget

android tabwidget意图选项卡刷新每一个命中

我想使用具有意图的子选项卡创建选项卡,这样当用户单击选项卡意图时,刷新.

每次用户单击选项卡我想要刷新并调用oncreate方法的子意图选项卡.

public class Tabs3 extends TabActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final TabHost tabHost = getTabHost();

        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("list")
                .setContent(new Intent(this, List1.class)));

        tabHost.addTab(tabHost.newTabSpec("tab2")
                .setIndicator("photo list")
                .setContent(new Intent(this, List8.class)));

        // This tab sets the intent flag so that it is recreated each time
        // the tab is clicked.
        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("destroy")
                .setContent(new Intent(this, Controls2.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
    }
}
Run Code Online (Sandbox Code Playgroud)

tabs android tabwidget android-intent

9
推荐指数
1
解决办法
1万
查看次数

TabHost/TabWidget - 缩放背景图像?

我需要缩放我的TabWidget背景图像,以便保持纵横比.
我正在使用带有TabWidget的TabHost.然后我使用setBackgroundDrawable来设置图像.

我发现了一个接近的答案在这里- 背景的标签控件忽略缩放.但是,我不确定在哪里添加新的Drawable代码.(使用HelloTabWidget示例,我的模块都没有使用RelativeLayout,我没有看到"tabcontent"的任何布局.)

我也找到了这个帖子--Android:缩放Drawable或背景图片?.根据它,听起来我必须预先缩放我的图像,这使得它们的可扩展性完全失败.

我还发现了另一个线程,其中有人将Drawable类子类化,因此它不会缩放,或者它会正确缩放.我现在找不到它,但是当你应该能够做一些像mTab.setScaleType(centerInside)这样简单的事情时,这似乎很难实现.

这是我的代码:

main.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"
    android:background="@drawable/main_background"> 
    <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="fill_parent"
            android:layout_weight="1"/>        
    <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_weight="0"/>
    </LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)

主要活动:

        tabHost.setOnTabChangedListener(new OnTabChangeListener() { 
            TabHost changedTabHost = getTabHost();
            TabWidget changedTabWidget = getTabWidget();
            View changedView = changedTabHost.getTabWidget().getChildAt(0);

            public void onTabChanged(String tabId) { 
                int selectedTab = changedTabHost.getCurrentTab();
                TabWidget tw = getTabWidget();

                if(selectedTab == 0) {
                    //setTitle("Missions Timeline");
                    View tempView = tabHost.getTabWidget().getChildAt(0);
                    tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_timeline_on));
                    tempView = tabHost.getTabWidget().getChildAt(1);
                    tempView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_map_off)); …
Run Code Online (Sandbox Code Playgroud)

android background scale tabwidget android-tabhost

7
推荐指数
1
解决办法
7950
查看次数

Android:使用TabHost和TabWidget自定义Tabs的外观

我之前发了一篇关于此事的帖子,但我觉得我现在可以(在阅读其他一些帖子后)更好地解释我想要的内容并将其改写,以便更好地理解.

我在开发指南上按照关于选项卡布局的教程进行操作,我设法用它创建选项卡,但我想对它进行一些自定义(我确实查看了其他帖子,但要么代码有很多错误,要么它没有不回答我在寻找的东西.

  1. 我遇到的第一个问题是测试大部分是在图标上而不是在图标下面(我使用了尺寸为48x48的图标,如开发指南中所推荐的).我希望选项卡与wrap_content一样.我也想改变文字大小(我认为它叫做标签).

  2. 我想使用十六进制三元组来更改选项卡的背景颜色,以便在两种情况之间进行更改:当此选项卡是选中的选项卡时,不选中的选项卡.

  3. 我希望能够更改选项卡下面的行的颜色,我找不到有关如何执行此操作的任何信息.

我目前用于创建新标签的代码是(来自开发指南):

    intent = new Intent().setClass(this, GroupsActivity.class);
    spec = tabHost.newTabSpec("groups").setIndicator("groups",
                      res.getDrawable(R.drawable.ic_tab_groups))
                  .setContent(intent);
    tabHost.addTab(spec);
Run Code Online (Sandbox Code Playgroud)

(groups是选项卡名称).

非常感谢帮助!

java tabs android tabwidget android-tabhost

7
推荐指数
2
解决办法
2万
查看次数

如何设置所选选项卡必须位于中间

我是Android新手,在我的项目中我有要求

即我有六个选项卡,但我只在屏幕上显示三个选项卡,其余选项卡我使用ScrollView.Here选中标签项必须在中间,首先当我进入屏幕我显示中间项目是活动的(即选中).

那很好但是当我滚动剩下的标签时,我怎么能把这个中间项目设置为中间?

任何人都可以提出解决方案的建议.

android scrollview horizontalscrollview tabwidget android-tabhost

7
推荐指数
2
解决办法
2723
查看次数

如何实现水平滚动标签?

我正在尝试实现此应用程序.目前我已经设计了标签,因为我有超过7个标签,它看起来太拥挤了.如何设计它以便tabwidget可以水平滚动.我在市场上的一些应用程序上看到了这个设计,但没有任何线索如何在我的应用程序中实现这一点.

我看到的一个应用程序有一个水平滚动视图,它自己滚动,当你按下特定的图像/按钮时,它会显示一些内容.它似乎不是我猜的标签.

那么有人对此有所了解吗?

android horizontalscrollview tabwidget android-tabhost android-tabs

7
推荐指数
2
解决办法
3万
查看次数

如何在android中删除Tabwidget中的填充或边距?

我想创建选项卡式应用程序.一切都很好,但是当我创建标签时.标签之间的空间太大了.我想删除这个填充或边距,但我不知道我该怎么做.有什么建议吗?

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">

    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="none" >
    <TabWidget
        android:id="@android:id/tabs"
        android:padding="0px"
        android:layout_margin="0px"

        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <TextView
            android:tag="tab0"
            android:text="Tab 1"
            android:padding="0px"
            android:layout_margin="0px"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            />
        <TextView
            android:tag="tab1"
            android:text="Tab 2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <TextView
            android:tag="tab2"
            android:text="Tab 3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <TextView
            android:tag="tab3"
            android:text="Tab 4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <TextView
            android:tag="tab4"
            android:text="Tab 5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <TextView
            android:tag="tab5"
            android:text="Tab 6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <TextView
            android:tag="tab6"
            android:text="Tab 7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
        <TextView
            android:tag="tab7"
            android:text="Tab …
Run Code Online (Sandbox Code Playgroud)

tabs android tabwidget

7
推荐指数
2
解决办法
5526
查看次数

如何在android中制作椭圆形tabhost

我试着按照预期的形状制作椭圆形tabhost.

在此输入图像描述

我尝试了以下代码.

    public class AndroidTabLayoutActivity extends TabActivity {
    TabHost tabHost;

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

        tabHost = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;
        intent = new Intent().setClass(this, PhotosActivity.class);
        View tabView = createTabView(this, "Updates");
        spec = tabHost.newTabSpec("tab1").setIndicator(tabView).setContent(intent);
        tabHost.addTab(spec);

        tabView = createTabView(this, "Events");
        intent = new Intent().setClass(this, SongsActivity.class);
        spec = tabHost.newTabSpec("tab2").setIndicator(tabView)
                .setContent(intent);
        tabHost.addTab(spec);

        TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
        final int tabChildrenCount = tabWidget.getChildCount();
        View currentView;
        for (int i = 0; i < tabChildrenCount; i++) {
            currentView = tabWidget.getChildAt(0);
            LinearLayout.LayoutParams currentLayout …
Run Code Online (Sandbox Code Playgroud)

android tabwidget tabactivity android-tabhost android-tabactivity

7
推荐指数
1
解决办法
752
查看次数

Light主题中的Android TabWidget

我有一个针对1.5框架的应用程序,并使用默认的灯光主题.使用具有此主题的选项卡窗口小部件时,选项卡图像几乎不可见,除了当前活动的选项卡之外,很难识别选项卡标题.

在默认的黑暗主题中,这些标签非常清晰,但这不是我非常满意的解决方案.我可以设置一个简单的设置,设置标签小部件以便在灯光主题中获得更好的可见性,还是我必须手动篡改图像和文本样式?

android themes tabwidget

6
推荐指数
1
解决办法
2万
查看次数

是否可以在本机TabWidget上使用ActionBarSherlock样式?

我想知道是否可以在本机TabWidget上应用ActionBarSherlock(v4.2.0)TabWidget主题?因此它会在ICS前机器人上看起来像Holo.如果你知道如何 - 请分享.

我发现的只有:https://gist.github.com/1126843但它似乎不再起作用了.

标准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="vertical" >

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android styles tabwidget actionbarsherlock

6
推荐指数
1
解决办法
910
查看次数

Tabhost-在Android选项卡中设置徽章位置

我是徽章概念的新手.在我的应用程序中,我想在一个选项卡上显示徽章.为此,我使用android-viewbadger.jar文件Android ViewBadger, 它正常工作4个标签,

    TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs);
    badge1 = new BadgeView(this, tabs, 1);
    badge1.setText("155");
    badge1.setBadgePosition(BadgeView.POSITION_BOTTOM_RIGHT);
    badge1.toggle();
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

当我在这里添加一个标签时,它看起来像这样

在此输入图像描述

我已经使用这些徽章属性

    badge1.setPadding(left, top, right, bottom);
    badge1.setTextSize(15);
    badge1.setBadgeMargin(5,5);
    badge1.setWidth(10);
Run Code Online (Sandbox Code Playgroud)

notifications tabs android tabwidget android-view

6
推荐指数
1
解决办法
3012
查看次数