Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android TabHost文本对齐_Android_Android Tabhost - Fatal编程技术网

Android TabHost文本对齐

Android TabHost文本对齐,android,android-tabhost,Android,Android Tabhost,我有一个非常简单的问题-我的TabHost上的选项卡文本没有正确对齐 注意“设置”在其余的下面。以前,这个(非常旧的)应用程序的目标是API 9,选项卡显示文本和图标,一切都很好。我最近更新了目标,外观和感觉发生了变化(这很好),文本没有正确对齐 主要布局: <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android"

我有一个非常简单的问题-我的TabHost上的选项卡文本没有正确对齐

注意“设置”在其余的下面。以前,这个(非常旧的)应用程序的目标是API 9,选项卡显示文本和图标,一切都很好。我最近更新了目标,外观和感觉发生了变化(这很好),文本没有正确对齐

主要布局:

<?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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:paddingBottom="0dp"/>
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</TabHost>
生成文件摘录:

compileSdkVersion = 25
buildToolsVersion = "23.0.3"
defaultConfig {
        minSdkVersion 14
        targetSdkVersion 25

        testInstrumentationRunner "com.redshedtechnology.common.MultiDexAndroidJUnitRunner"
        testFunctionalTest true

        multiDexEnabled true
    }
我尝试更改文本大小:

<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">12sp</item>
    </style>
@style/CustomTabWidget
@样式/自定义TabWidgetText
12便士
这修复了对齐问题,但完全破坏了选项卡显示

编辑:此处的最小完整示例:


这不使用自定义选项卡布局,而是默认设置。它完全展示了我的应用程序的行为,几乎没有任何代码或布局,非常简单。如果你想试试,这是一个zipped Android Studio项目。

你的绘图工具看起来怎么样?格式,大小,…?68x32 PNG。我将看看没有它们会发生什么,因为它们无论如何都不会显示。我从
setIndicator
调用中删除了Drawable,它没有改变任何东西。我想首先要评估的是,为什么选项卡的图标没有显示。请阅读这个伟大的答案,并检查,你是否可以使图标出现,以及他们是否以及“偏移到底部”的标签。如果图标看起来没有问题,我会继续评估,是否是因为字符串的长度和可用空间。实际上,我更喜欢没有图像的选项卡,所以我希望保持显示的方式,并修复对齐。我会看看答案是什么,也许文本的自定义布局是必要的。
<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">12sp</item>
    </style>