材质按钮-样式无法正确应用,丑陋如地 [英] Material Button - Styles not being applied correctly, ugly as hell

查看:62
本文介绍了材质按钮-样式无法正确应用,丑陋如地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

丑陋的结果:

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                             xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
                                             android:layout_height="match_parent">
    <com.google.android.material.button.MaterialButton
            android:id="@+id/material_text_button"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Contact"
            android:layout_marginTop="8dp"
            app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
            android:layout_marginStart="59dp"/>

    <com.google.android.material.button.MaterialButton
            android:id="@+id/material_button"
            style="@style/Widget.MaterialComponents.Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Default"
            app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="114dp"
            android:layout_marginTop="109dp" app:layout_constraintTop_toBottomOf="@+id/material_text_button"/>


</android.support.constraint.ConstraintLayout>

颜色:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#008577</color>
    <color name="colorOnPrimary">#FFFFFF</color>
    <color name="colorPrimaryDark">#00574B</color>
    <color name="colorAccent">#D81B60</color>
    <color name="colorOnSurface">#000000</color>
    <color name="colorOnSurfaceSecondary">#d3d3d3</color>
    <color name="colorOnBackground">#000000</color>
</resources>

成绩:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.material:material:1.0.0-beta01'
}

我在这里做错了什么?默认情况下真的很丑吗?这是在API 21上.

What am I doing wrong here? Is it really meant to be so ugly by default? This is on API 21.

材料链接: https://material.io/develop/android/components /material-button/

推荐答案

事实证明,当我在模拟器上运行该应用程序时,按钮的外观看起来不错.意思是,我所做的没有错.

As it turns out, when I run the app on the emulator, the buttons have a proper good look to them. Meaning, there is nothing wrong with what I am doing.

Android Studio预览版似乎在这里是错误的,我只能怀疑是否可以解决该问题.

The Android Studio Preview seems to be in the wrong here, I can only wonder if that can be fixed.

这篇关于材质按钮-样式无法正确应用,丑陋如地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆