How to change Toolbar Navigation and Overflow Menu icons (appcompat v7)?

To change the navigation icon you can use: Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.my_icon); To change the overflow icon you can use the method: toolbar.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.ic_my_menu); If you would like to change the color of the icons you can use: with a Material Components Theme (with a MaterialToolbar for example): <com.google.android.material.appbar.MaterialToolbar android:theme=”@style/MyThemeOverlay_Toolbar” …> <style … Read more

“Back button” using getSupportActionbar and appcompat v7 toolbar

Add this method in onCreate(): getSupportActionBar().setDisplayHomeAsUpEnabled(true); Then override the onOptionItemSelected() as below: @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed(); return true; default: return super.onOptionsItemSelected(item); } }

ComponentActivity vs AppCompactActivity in Android Jetpack Compose

AppCompatActivity extends FragmentActivity which extends ComponentActivity. ComponentActivity has all you need for a Compose-only app. If you need AppCompat APIs, an AndroidView which works with AppCompat or MaterialComponents theme, or you need Fragments then use AppCompatActivity. Note: it requires at least the AppCompat 1.3.0 version.

android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawableWithShadow

I get this error when calling setBackgroundColor() method, which is defined in View class. cardView.setBackgroundColor(Color.parseColor(“#ffffcc”)); Instead setCardBackgroundColor() method should be called, which is specific to CardViews and defined within CardView class. This code setting both background colour and the corner radius works for me: cardView.setCardBackgroundColor(Color.parseColor(“#ffffcc”)); cardView.setRadius(50);

How to add indeterminate progressbar

Jetpack compose You can use the LinearProgressIndicator or CircularProgressIndicator // Indeterminate CircularProgressIndicator() LinearProgressIndicator() // Determinate (specify the progress value with a fixed value or animateFloatAsState to animate it) CircularProgressIndicator(progress = ..) LinearProgressIndicator(progress = ..) Example: var progress by remember { mutableStateOf(0.1f) } LinearProgressIndicator( backgroundColor = Color.White, progress = progress, color = Blue ) Material Components … Read more

How to enable homeAsUp or call setDisplayHomeAsUpEnabled() on standalone toolbar with appcompat v21

@Pedro Oliveira’s solution worked. I could even find the drawable that the AppCompat library uses (and therefore is already included in the apk). What more it’s also mirrored, so it works both for ltr, rtl locales: actionbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha); and this is it alltogether, with the correction from @VictorYakunin public class SettingsActivity extends PreferenceActivity { @Override protected … Read more

Android v21 Theme.Appcompat color accent is ignored, no padding on dialogs

About the accent color. You are using a AppCompat theme so you should remove Android from the namespace inside your theme. <style name=”AppTheme_Light” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”colorPrimary”>@color/abc1</item> <item name=”colorPrimaryDark”>@color/abc2</item> <item name=”colorAccent”>@color/abc3</item> </style> About the dialog. AppCompat doesn’t support it (as I know). You can try to use this style in your values-v21 folder: <style name=”Theme” parent=”FrameworkRoot.Theme”> … Read more

CoordinatorLayout using the ViewPager’s RecyclerView

Chris Banes has posted a sample on Github which shows exactly what you want to do. Here is the xml file that defines how one can indirectly attach a coordinator layout to the viewpager’s fragments. <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/main_content” android:layout_width=”match_parent” android:layout_height=”match_parent”> <android.support.design.widget.AppBarLayout android:id=”@+id/appbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:background=”?attr/colorPrimary” app:popupTheme=”@style/ThemeOverlay.AppCompat.Light” app:layout_scrollFlags=”scroll|enterAlways” /> <android.support.design.widget.TabLayout … Read more

Error in styles_base.xml file – android app – No resource found that matches the given name ‘android:Widget.Material.ActionButton’

Go to your Android SDK installed directory then extras > android > support > v7 > appcompat. in my case : D:\Software\adt-bundle-windows-x86-20140702\sdk\extras\android\support\v7\appcompat once you are in appcompat folder ,check for project.properties file then change the value from default 19 to 21 as : target=android-21. Save the file and then refresh your project. Then clean the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)