【问题标题】:Material Button not properly showing on Preview材质按钮未正确显示在预览中
【发布时间】:2019-04-13 06:25:35
【问题描述】:

这个问题和我的另一个问题有关:Material Button - Styles not being applied correctly, ugly as hell

在模拟器上运行时工作正常。 API 为 21,Android Studio v3.2.1。有没有办法解决这个问题?

预览:

布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

    <com.google.android.material.button.MaterialButton
            android:id="@+id/material_button"
            style="@style/Widget.MaterialComponents.Button.TextButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Test" app:layout_constraintStart_toStartOf="parent"
            android:layout_marginStart="76dp" app:layout_constraintTop_toTopOf="parent"
            android:layout_marginTop="108dp"/>

</android.support.constraint.ConstraintLayout>

Gradle:

    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'

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.test.materialbuttontest01">

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/Theme.MaterialComponents.Light.NoActionBar">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

【问题讨论】:

  • 我建议您参考您之前的问题,否则人们可能会开始将此标记为重复。在我检查了您的(新)答案之前,我当然认为两者都是一样的。
  • 完成。认为最好只发布一个新问题,而不是试图在另一个问题上得到答案。
  • 绝对是。你做了正确的事情。你的标题和内容都差不多,所以我建议链接。

标签: android material-design


【解决方案1】:

选择另一个主题即可。

【讨论】:

  • 在文字中包含图片中的细节
猜你喜欢
  • 2022-10-24
  • 2018-02-05
  • 1970-01-01
  • 2017-12-19
  • 2018-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-03
相关资源
最近更新 更多