相关疑难解决方法(0)

android设计TabLayout标签的文字大小

我无法更改设计库tablayout(android.support.design.widget.TabLayout)选项卡的文本大小.

我设法通过在TabLayout中指定tabTextAppearance来更改它

app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
Run Code Online (Sandbox Code Playgroud)

以下风格

<style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse">
    <item name="android:textSize">14sp</item>
</style>
Run Code Online (Sandbox Code Playgroud)

但我有2个副作用:

1)我丢失了所选标签的强调色

2)标签文本不再大写.

android text-size android-tablayout

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

Android:以编程方式更改选项卡文本颜色

我有一个像这样的TabHost:

<?xml version="1.0" encoding="utf-8"?>
 <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost"
android:background="@drawable/tabs_bg">

<LinearLayout 
    android:id="@+id/LinearLayout01"
    android:orientation="vertical" 
    android:layout_height="fill_parent"
    android:layout_width="fill_parent">
    <TabWidget 
        android:id="@android:id/tabs"
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent"
        android:layout_marginBottom="5dip">
    </TabWidget>
    <FrameLayout 
        android:id="@android:id/tabcontent"
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent">
    </FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我正在以编程方式向此TabHost添加标签,如下所示:

tabHost = (TabHost)findViewById(android.R.id.tabhost);
    tabHost.setOnTabChangedListener(this);

    /* tid1 is firstTabSpec Id. Its used to access outside. */
    TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
    TabSpec secondTabSpec = tabHost.newTabSpec("tid2");
    TabSpec ThirdTabSpec = tabHost.newTabSpec("tid3");

    /* TabSpec setIndicator() is used to set name for the tab. */
    /* TabSpec setContent() is used to set content for a particular tab. */ …
Run Code Online (Sandbox Code Playgroud)

android android-widget

16
推荐指数
3
解决办法
5万
查看次数

滑动选项卡布局文本是大写的

嗨,我在我的应用程序中使用滑动选项卡布局,这一切都很好.我唯一不理解的是为什么我的标签文本是大写的.

我打印了选项卡在滑动选项卡类中的文本,它们不是大写的.我环顾四周,没有调用toUpperCase方法.

以下是设置文本的类中的代码:

  private void populateTabStrip() {
        final PagerAdapter adapter = mViewPager.getAdapter();
        final View.OnClickListener tabClickListener = new TabClickListener();

        for (int i = 0; i < adapter.getCount(); i++) {
            View tabView = null;
            TextView tabTitleView = null;

            if (mTabViewLayoutId != 0) {
                // If there is a custom tab view layout id set, try and inflate it
                tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip,
                        false);
                tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            }

            if (tabView == null) {
                tabView = createDefaultTabView(getContext());
            }

            if (tabTitleView == null && …
Run Code Online (Sandbox Code Playgroud)

android android-tabs

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

选项卡的android字体大小

我问过几次这个任务,但我没有解决方案:(我的问题是,我有一个带有标签活动的Android应用程序,我必须设置我的标签的字体大小,但我不知道怎么样.

在我的活动中,我以编程方式设置我的标签:

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText("MY TAB 1"));
    tabLayout.addTab(tabLayout.newTab().setText("MY TAB 2"));
    tabLayout.addTab(tabLayout.newTab().setText("MY TAB 3"));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
Run Code Online (Sandbox Code Playgroud)

问题是,最后的1 - 2个字母将被剪切,所以我必须设置较小的字体大小,但如何?

我希望有人能帮助我.

tabs android

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