Here's my class that extends AppCompatActivity:
class MainActivity : AppCompatActivity() {
private var TAG: String = this.toString()
I've didn't add it entirely because it has no regions that tweaks the theme or anything, it's just simple coding like findViewById.
Here's the XML that it uses:
<layout>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Theme.AppCompat"
>
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</com.google.android.material.appbar.AppBarLayout>
<!-- Main content -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/effect_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floating_add_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
app:srcCompat="@drawable/ic_add" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
As you can see, I already added an AppCompat theme. I tried many themes from the many questions and answers here on StackOverflow. If I extend Activity()
instead of AppCompatActivity
it works but its not the intended solution.
Update:
a solution was to change
<activity
android:name="com.github.cythara.MainActivity"
android:label="Main">
</activity>
to include a theme:
<activity
android:name="com.github.cythara.MainActivity"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:label="Main">
</activity>
why it works?