【发布时间】:2019-09-03 10:32:25
【问题描述】:
您好,我想使用材料按钮,例如以下链接中的按钮: https://material.io/components/buttons/#text-button
但是当我添加时:
compile group: 'com.google.android.material', name: 'material', version: '1.1.0-alpha01'
并使用:
我的代码在下面
我已经使用了许多 com.google.android.material 实现,但我的一些尝试不能这样做:
implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.0.0-alpha1'
应用分级:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.esppad.fansy4"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
// https://mvnrepository.com/artifact/com.google.android.material/material
compile group: 'com.google.android.material', name: 'material', version: '1.1.0-alpha01'
//implementation 'com.google.android.material:material:1.1.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
我的主要活动代码是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center">
<com.google.android.material.button.MaterialButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:text="material"
app:strokeColor="@color/colorPrimary"
app:strokeWidth="2dp"
android:layout_marginBottom="10dp"
/>
<Button
android:id="@+id/button"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
我的构建等级是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】:
标签: android material-design android-button material-components material-components-android