Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.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
Java 工具栏标题和副标题显示的字体大小错误_Java_Android_Textview_Android Toolbar - Fatal编程技术网

Java 工具栏标题和副标题显示的字体大小错误

Java 工具栏标题和副标题显示的字体大小错误,java,android,textview,android-toolbar,Java,Android,Textview,Android Toolbar,在为我的工具栏实现了标题和副标题后,出于某种原因使用了错误的字体大小。为了解决这个问题,需要做些什么 爪哇 toolbarC.xml 将工具栏的高度增加到?actionBarSize将textSize添加到每个TextView。像这样试试 <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar android:id="@+id/toolbar_2lines" android:layout

在为我的工具栏实现了标题和副标题后,出于某种原因使用了错误的字体大小。为了解决这个问题,需要做些什么

爪哇

toolbarC.xml


将工具栏的高度增加到?actionBarSize

将textSize添加到每个TextView。像这样试试

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_2lines"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:id="@+id/header_text_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00FFFFFF"
    android:gravity="center_vertical"
    android:orientation="vertical">

    <TextView
        android:id="@+id/toolbar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="18sp"
        style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"/>

    <TextView
        android:id="@+id/toolbar_subtitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="12sp"
        style="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"/>
</LinearLayout>

添加这一行,可能是使用app_名称作为标题 getSupportActionBar.setDisplayShowTitleEnabledfalse;
尝试使用dp而不是sp

发现问题并解决了它。在我的项目中有一个隐藏的工具栏文本视图副本,重复的标题和副标题是部署我的应用程序时显示给我的

我想你的工具栏id有问题,只是交叉检查了一下,你能解释一下是什么问题吗?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    android:id="@+id/toolbarC"
    android:layout_width="match_parent"
    android:layout_height="?actionBarSize"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:id="@+id/header_text_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#00FFFFFF"
        android:gravity="center_vertical"
        android:orientation="vertical">

        <TextView
            android:id="@+id/toolbar_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"/>

        <TextView
            android:id="@+id/toolbar_subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"/>
    </LinearLayout>
</android.support.v7.widget.Toolbar>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_2lines"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:id="@+id/header_text_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00FFFFFF"
    android:gravity="center_vertical"
    android:orientation="vertical">

    <TextView
        android:id="@+id/toolbar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="18sp"
        style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"/>

    <TextView
        android:id="@+id/toolbar_subtitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="12sp"
        style="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"/>
</LinearLayout>