【问题标题】:Why materialButton closes my application?为什么 materialButton 会关闭我的应用程序?
【发布时间】:2019-04-13 01:15:15
【问题描述】:

我是 android 开发的新手,但是我在模拟和生成 apk 时遇到了一个错误,在我的设备中使用 api 26 一切正常,但在任何其他使用另一个 api 的设备中,它以一种意想不到的方式关闭...按部分代码编码,模拟和生成apk部分我注意到android.support.design.button.MaterialButton会导致意外关闭,如果我有一个有效的示例代码,我不明白为什么会出现该错误在任何设备上。

这里是我的 gradle 应用的图片以及我在哪里应用了 materialButton

[https://i.stack.imgur.com/dNo5L.png][1]

[https://i.stack.imgur.com/FUEq0.png][2]

这是我的 gradle 应用程序

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.ts.ts.ts"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}


buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}}



dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
api 'com.android.support:design:28.0.0'



implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
implementation 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
implementation 'com.android.volley:volley:1.1.1'

implementation 'com.google.code.gson:gson:2.8.2'

implementation 'com.android.support:support-v4:28.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.google.android.gms:play-services-plus:16.0.0'
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'}

这是我应用materialButton的xml

<android.support.design.button.MaterialButton
            android:id="@+id/cancel_button"
            style="@style/Widget.Shrine.Button.textButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="12dp"
            android:layout_marginRight="12dp"
            android:layout_toStartOf="@id/next_button"
            android:layout_toLeftOf="@id/next_button"
            android:text="@string/shr_button_cancel" />

请帮帮我!!!!

【问题讨论】:

标签: android material-design material-ui


【解决方案1】:

styles.xml 文件中,将应用程序主题的基础更改为来自材料设计库的主题。例如:

<style name="AppTheme" parent="Theme.MaterialComponents.Light">

【讨论】:

    猜你喜欢
    • 2016-06-23
    • 2022-01-24
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-03
    相关资源
    最近更新 更多