我正在尝试在 Android Studio 中使用 ConstraintLayout 并且我正在以这种方式构建片段,特别是我使用 android:layout_height="match_parent"。
这是我的代码。
<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"
android:background="@android:color/holo_blue_light"
tools:context="com.saffru.colombo.soccerstats.match.PrePartitaFragment">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Prepartita"
android:textColor="@android:color/black"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/txtdate"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/txtdate"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/txtdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:focusable="false"
android:hint="Tocca per inserire la data*"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<ListView
android:id="@+id/ListView01"
android:layout_width="match_parent"
android:layout_height="300sp"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_avversario" />
<EditText
android:id="@+id/et_avversario"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:ems="10"
android:hint="Avversario"
android:inputType="textPersonName|textCapSentences"
app:layout_constraintEnd_toStartOf="@+id/ListView01"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/ListView01"
app:layout_constraintTop_toBottomOf="@+id/et_luogo" />
<CheckBox …Run Code Online (Sandbox Code Playgroud) 当我将我的项目与 Android Studio 中的 Gradle 文件同步时,出现以下错误:
在 DefaultConfig_Decolated{name=main、dimension=null、minSdkVersion=null、targetSdkVersion=null、renderscriptTargetApi=null、renderscriptSupportModeEnabled=null、renderscriptSupportModeBlasEnabled=null、renderscriptNdkModeEnabled=null、versionCode=null 上找不到参数 [16] 的方法 minSdkersion() 、 versionName=null、applicationId=com.saffru.colombo.giocoepoche、testApplicationId=null、testInstrumentationRunner=null、testInstrumentationRunnerArguments={}、testHandleProfiling=null、testFunctionalTest=null、signingConfig=null、resConfig=null、mBuildConfigFields={}、mResValues ={}、mProguardFiles=[]、mConsumerProguardFiles=[]、mManifestPlaceholders={}、mWearAppUnbundled=null},类型为 com.android.build.gradle.internal.dsl.DefaultConfig。
我尝试更改 minSdkersion 但错误仍然存在。
这是我的 Gradle 模块
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.saffru.colombo.giocoepoche"
minSdkersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
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.android.volley:volley:1.1.1'
}
Run Code Online (Sandbox Code Playgroud)
这是我的 Gradle 项目
// …Run Code Online (Sandbox Code Playgroud) android ×2