ImageView
,TextView
,LinearLayout
等。如果我将光标放在元素上,则会看到“ Element ImageView / View / TextView ...在这里是不允许的...“
如果我开始编写“ TextV”,IDE不会告诉我“ TextView”之类的选项
如果我选择“设计”-按钮,则显示的是布局。而且我可以构建我的应用程序并且它可以工作。
我正在尝试:清理生成,重建,删除兑现,使兑现无效,删除文件夹“ .idea”,但是我遇到了这个问题。
例如,我的.xml
文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:id="@+id/all_content_items"
android:layout_height="wrap_content"
android:background="#ffffff">
<ImageView
android:id="@+id/avatar"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="16dp"
android:layout_centerVertical="true"
android:src="@mipmap/container_orange_new" />
<ImageView
android:id="@+id/viewed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/point"
android:layout_alignParentEnd="true"
android:layout_marginEnd="16dp"
android:layout_marginTop="37dp"/>
<TextView
android:id="@+id/number_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_toEndOf="@id/avatar"
android:layout_marginTop="16dp"
android:text="Уведомление по контейнеру"
android:textColor="#033E30"
android:alpha="0.48"
android:textSize="12sp" />
<TextView
android:id="@+id/date_creation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginRight="15dp"
android:layout_marginStart="279dp"
android:alpha="0.48"
android:text="контейнер"
android:textColor="#033E30" />
<TextView
android:id="@+id/count_of_containers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/date_creation"
android:textColor="#033E30"
android:layout_marginTop="16dp"
android:layout_marginLeft="14dp"
android:text="2"
android:textSize="12sp"
android:textAlignment="textEnd"/>
<TextView
android:id="@+id/textNotification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/number_order"
android:layout_toEndOf="@id/avatar"
android:text="Транспортировка в Пекин"
android:paddingEnd="20dp"
android:layout_marginTop="2dp"
android:layout_marginStart="16dp"
android:textColor="#000000"
android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/textNotification"
android:layout_alignParentStart="true"
android:layout_marginStart="0dp"
android:layout_marginTop="12dp"
android:background="#c6d8d3">
</View>
</RelativeLayout>
我的.gradle
文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.royallogistics.yegor.royallogistics"
minSdkVersion 20
targetSdkVersion 28
versionCode 3
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
resValue("string", "PORT_NUMBER", "8080")
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4:28.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'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.0.1'
implementation 'com.melnykov:floatingactionbutton:1.3.0'
implementation 'com.android.support:design:28.0.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
implementation "com.android.support:support-fragment:28.0.0"
implementation 'com.github.esafirm.android-image-picker:imagepicker:1.13.1'
implementation 'com.github.esafirm.android-image-picker:rximagepicker:1.13.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
}
当我用gradles文件同步项目时,就可以了。如何解决?
答案 0 :(得分:0)
添加此
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
到您的根元素。 如果这不起作用,请在“文件”标签中尝试使缓存无效/重新启动
答案 1 :(得分:0)
尝试再次导入您的项目,此问题可能会解决