相关疑难解决方法(0)

如何在设计支持库的TabLayout中的Tabs之间设置分隔符?

我正在使用新android.support.design.widget.TabLayoutv7-appcompat库,并发现了一个问题,没有办法在选项卡之间设置分隔符,不知道是否有.

我已经成功配置了寻呼机适配器,并且标签看起来不错,但无法在标签之间设置分隔线.

我想要这种类型的标签

Tab1 | Tab2 | Tab3
Run Code Online (Sandbox Code Playgroud)

但目前正在展示

Tab1  Tab2  Tab3
Run Code Online (Sandbox Code Playgroud)

我的xml是

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >

        <include layout="@layout/toolbar" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tablayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/shape_tabbar_background"
            app:tabIndicatorColor="@android:color/white"
            app:tabIndicatorHeight="4dp" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

我正在添加标签

viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setOffscreenPageLimit(2);
    adapter = new TabAdapterLoginActivity(getSupportFragmentManager(),
            titles);
    viewPager.setAdapter(adapter);
    tabLayout = (TabLayout) findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(viewPager);
Run Code Online (Sandbox Code Playgroud)

android androiddesignsupport

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

Android删除tabwidget中选项卡之间的空格

我已经制作了一个应用程序,其中包含HelloTabActivity中的标签,这些标签之间也有空格,任何人都可以建议如何删除此空间,并且标签下方还有一条灰色线条如何删除?

在此输入图像描述

main.xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost
    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"
        android:padding="5dp" >
        <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbars="none">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </HorizontalScrollView>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTheme" parent="@android:style/Theme">
    <item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
    <item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" 
    parent="@android:style/TextAppearance.Widget.TabWidget">
    <item name="android:textSize">10sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textColor">#1589FF</item>
    <item name="android:padding">3dip</item>
</style>


</resources>
Run Code Online (Sandbox Code Playgroud)

活动

public class InfralineTabWidget extends TabActivity{

public void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud)

android tabwidget android-layout android-style-tabhost android-tabhost

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

自定义ActionBar TabBar(ActionBarSherlock)

我已经坚持了几天这个问题了.任何人都可以帮我自定义ActionBar(NavigationMode NAVIGATION_MODE_TABS)下方显示的选项卡吗?

我基本上想要更改选项卡的背景颜色和当前所选选项卡的下划线颜色.到目前为止,这是我所做的,但它不起作用.我在用ActionBarSherlock.

<style name="Theme.Styled" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/Widget.Theme.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Theme.Styled.ActionBar</item>

    <item name="actionBarTabBarStyle">@style/customActionBarTabStyle</item>
    <item name="android:actionBarTabBarStyle">@style/customActionBarTabStyle</item>

    <item name="actionBarTabBarStyle">@style/customActionBarTabBarStyle</item>
    <item name="android:actionBarTabBarStyle">@style/customActionBarTabBarStyle</item>

    <item name="actionBarTabTextStyle">@style/customActionBarTabTextStyle</item>
    <item name="android:actionBarTabTextStyle">@style/customActionBarTabTextStyle</item>
</style>

<style name="customActionBarTabStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabView">
    <item name="android:background">@color/red</item>

    <item name="android:textSize">12dp</item>

</style>

<style name="customActionBarTabBarStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabBar">
    <item name="android:background">@color/red</item>
</style>

<style name="customActionBarTabTextStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabText">
    <item name="android:titleTextStyle">@style/Theme.Styled.ActionBar.TitleTextStyle</item>
    <item name="android:textStyle">bold</item>
</style>

<style name="Widget.Theme.Styled.ActionBar" parent="Widget.Sherlock.ActionBar">
    <item name="android:background">#A9E2F3</item>
    <item name="background">#A9E2F3</item>
    <item name="android:titleTextStyle">@style/Theme.Styled.ActionBar.TitleTextStyle</item>
</style>

<style name="Theme.Styled.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/red</item>
    <item name="android:textStyle">bold</item>
</style>

<style name="Animations" />
Run Code Online (Sandbox Code Playgroud)

android android-theme android-actionbar

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

自定义FragmentTabHost在底部设置TabWidget

目前我正在尝试为我的项目实现FragmentTabHost.我仍然对这些碎片很新,但我发现它在重用布局等方面非常好,这就是为什么我想进一步推动它.现在我阅读有关如何使用片段创建Tabs的教程,我在本教程中介绍了:

http://maxalley.wordpress.com/2013/05/18/android-creating-a-tab-layout-with-fragmenttabhost-and-fragments/

现在这个工作得很好,除了tabWidget位于我的布局之上,我希望它在底部.我发现在初始化所有选项卡后我需要设置tabWidget,所以我尝试添加这些代码:

mTabWidget = (TabWidget) findViewById(android.R.id.tabs);

    mTabWidget.setBackgroundColor(Color.WHITE);
    mTabWidget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
    mTabWidget.setGravity(Gravity.BOTTOM);
Run Code Online (Sandbox Code Playgroud)

现在这个已经消除了分隔符并改变了颜色,但显然不会将我的Widget放在我的布局的底部.现在我该怎么做?

我还尝试编辑Tabhost xml并将TabWidget放在FrameLayout之后但没有任何反应.这是xml:

    <android.support.v4.app.FragmentTabHost
                xmlns:android="http://schemas.android.com/apk/res/android"
                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" >

                <FrameLayout
                        android:id="@+id/tabFrameLayout"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1" />

                <TabWidget
                        android:id="@android:id/tabs"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="0"
                        android:orientation="horizontal"
                        />

            </LinearLayout>

        </android.support.v4.app.FragmentTabHost>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-xml android-fragments

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

操作栏选项卡选择分隔线颜色

在下面的android 开发人员指南中,您会看到标签下方的浅蓝色边缘.我尝试用另一种颜色来塑造这个小边缘,但我没有成功.

同时我成功地设置了动作栏和标签的样式.但我唯一无法取得成功的是改变那个小小的蓝色边缘.我甚至不知道它在指南中是如何调用的.因为分隔符是所有水龙头之间的小条纹:

[气球| 自行车| ANDROIDS | PASTRIES]

有人可以帮我弄这个吗?我必须使用哪种风格来改变这种颜色?

以下行没有成功:

<item name="android:actionBarDivider">@drawable/divider</item>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

android styles android-actionbar

5
推荐指数
1
解决办法
8385
查看次数