android - 为什么 Switch 在 Nexus 5 版本 6.0.1 中显示不同?

标签 android user-interface android-xml nexus-5

enter image description here

现在的输出就像上面一样...不显示 SWITCH ..仅显示开/关

这是我的 Switch 代码...

所有其他设备输出都很好,但在 NExus 5 中它只显示开/关,而不是开关/切换开关。

<LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="0.7"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="5dp"
                        android:text="Save recorded call? "
                        android:textColor="@color/black"
                        android:textStyle="bold" />

                    <Switch
                        android:id="@+id/recSwitch"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textOff="Off"
                        android:textOn="On" />
                </LinearLayout>

预先感谢您的帮助..建议可以接受..

最佳答案

添加你的依赖

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.3'
}

在你的 xml 中

<LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.7"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:text="Save recorded call? "
                    android:textColor="@color/black"
                    android:textStyle="bold" />

                <android.support.v7.widget.SwitchCompat
                     android:id="@+id/switch_compat2"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="Switch Compat"
                     app:showText="false"/>
            </LinearLayout>

关于android - 为什么 Switch 在 Nexus 5 版本 6.0.1 中显示不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38870900/

相关文章:

java - 如何像在 xml 中那样改变 java 中 textview 的位置

android - 识别android中的物理设备

javascript - PhoneGap Cordova > 3.1.0 inAppBrowser 不工作

java - 具有组件固定宽度和高度的 GridLayout?

android - 在实现Firebase Phone Auth时,我从顶部得到一个奇怪的黑条动画

java - 加载大量文本时在 JavaFX 2 中加速 TextArea 的方法?

android - 为什么 TextToSpeech.getLanguage() *有时* 会返回 null?

android - Google Cardboard for Unity 只渲染一个光源

android - 为什么在 Android 中使用 xml 文件以及它们提供什么功能。

android - 如何在相对布局中的 ImageView 上方添加水平 1px 线?