材质按钮-样式未正确应用,丑陋得令人发指

时间:2018-11-09 11:28:56

标签: android material-design

丑陋的结果:

enter image description here

我的布局:

<?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上。

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

1 个答案:

答案 0 :(得分:0)

事实证明,当我在模拟器上运行该应用程序时,这些按钮的外观应适当。意思是,我所做的没有错。

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