【问题标题】:Xamarin Forms - Android tab text to camel caseXamarin Forms - Android 选项卡文本到驼峰式大小写
【发布时间】:2020-06-15 01:42:44
【问题描述】:

我正在尝试将 Xamarin Forms Android 应用程序上的选项卡文本转换为驼峰式大小写。像这样: How to change ActionBar Tab textStyle?

我已经尝试了很多关于堆栈溢出的示例,但都无法正常工作。下面是我的styles.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <resources>

    <style name="Theme.Splash"
        parent="android:Theme">
    <item name="android:windowBackground">@drawable/splashscreen</item>
    <item name="android:windowNoTitle">true</item>
    </style>

  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#96BCE3</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>

    <item name="android:colorPressedHighlight">@color/ListViewSelected</item>
    <item name="android:colorLongPressedHighlight">@color/ListViewHighlighted</item>
    <item name="android:colorFocusedHighlight">@color/ListViewSelected</item>
    <item name="android:colorActivatedHighlight">@color/ListViewSelected</item>
    <item name="android:activatedBackgroundIndicator">@color/ListViewSelected</item>

    <item name="android:textAllCaps">false</item> <!-- This works for buttons not tab page text -->"

  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#96BCE3</item>
  </style>

</resources>

谢谢 保罗。

【问题讨论】:

    标签: android xamarin.forms


    【解决方案1】:

    请按照以下路径打开Tabbar.xml文件

    然后像下面的代码一样添加app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
    
        app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
    
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:tabIndicatorColor="@android:color/white"
        app:tabGravity="fill"
        app:tabMode="fixed" />
    

    这里正在运行 GIF。

    【讨论】:

    • 如果此回答对您有帮助,请采纳(点击此回答左上角的☑️)将对有类似问题的其他人有所帮助
    • 太棒了,非常感谢。我几乎放弃了尝试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2014-10-22
    • 1970-01-01
    • 2016-05-28
    相关资源
    最近更新 更多