【发布时间】:2018-07-23 10:08:25
【问题描述】:
我正在尝试更改 textview、复选框、按钮和 android.support.design.widget.TextInputLayout 的默认字体。为了清楚说明,我设置了“android:fontFamily">cursive
它似乎在 Android Studio 预览中正确显示,但在 Emulator 中显示不正确,如下所示。另请注意,密码(提示)似乎在两者中都不起作用。希望您能帮助说明发生这种情况的原因。
styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">#ed328b</item>
<item name="android:titleTextColor">#ed328b</item>
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">cursive</item>
</style>
<style name="TextLabel" parent="Widget.Design.TextInputLayout">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">#ed328b</item>
<item name="android:textSize">14sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">#ed328b</item>
<item name="android:textColor">#ed328b</item>
<item name="colorControlNormal">#ed328b</item>
<item name="colorControlActivated">#ed328b</item>
<item name="android:textColorSecondary">#ed328b</item>
<item name="android:textColorPrimary">#ed328b</item>
<item name="android:fontFamily">cursive</item>
</style>
activity_main.xml:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel"
android:layout_marginTop="@dimen/space_2">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="textEmailAddress"
android:hint="@string/signin_emailaddress"
android:id="@+id/txtEmail" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel"
android:layout_marginTop="@dimen/space_2">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="textPassword"
android:hint="@string/signin_password"
android:id="@+id/txtPassword" />
</android.support.design.widget.TextInputLayout>
<CheckBox
android:id="@+id/rememberBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_gravity="start"
android:text="remember my email and password"
android:textAlignment="center"
android:textColor="#ed328b"
android:textSize="11dp" />
【问题讨论】:
-
设置
fontFamilyofEditText
标签: android android-studio fonts textview