Я добавил простую кнопку виджета к моей Android активности:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="@style/Theme.AppCompat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="4sp"
android:layout_marginTop="1sp"
android:layout_marginRight="4sp"
android:orientation="vertical">
<ListView
android:id="@+id/orders_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="auto" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="@drawable/ic_add"
android:contentDescription="fazer pedido"
android:layout_margin="16dp" />
</LinearLayout>
Тогда я получаю
android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class android.support.design.widget.FloatingActionButton
Вот мои зависимости gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'org.json:json:20190722'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Я перепробовал все решения здесь на stackoverflow. Некоторые упоминают использование backgroundTint, но я даже не использую это. Некоторые другие упоминают о компактной библиотеке v7, но я использую androidx. Так что эта проблема выглядит как новая, отличная от других
Не знаю, помогает ли это, но это мое занятие:
public class OrdersActivity extends AppCompatActivity implements AbsListView.OnScrollListener{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_orders);