AppCompat_v7 Toolbar as actionbar not showing ‘always’ actions from menu, but API Toolbar does

Per the Action Bar training, you have to use the app:showAsAction attributes rather than the android:showAsAction attribute: Notice that the showAsAction attribute above uses a custom namespace defined in the <menu> tag. This is necessary when using any XML attributes defined by the support library, because these attributes do not exist in the Android framework … Read more

How to listen for state change in SwitchCompat widget?

static Boolean isTouched = false; switchButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { isTouched = true; return false; } }); switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isTouched) { isTouched = false; if (isChecked) { } else { } } } }); Try this!

Video player lights out mode in Android using appcompat-v7

I’ve found fitssystemwindows pretty unreliable as well when you want some elements of the view hierarchy to be fullscreen and some elements to be below the status bar or action bar. But I’ve never seen the action bar behind the status bar. Is the Toolbar set as the activity actionbar? Are you using Window.FEATURE_ACTION_BAR_OVERLAY? Anyway, … Read more

The application icon does not show on action bar

You are using the AppCompat version 21+ and it is normal. The Action Bar follows the material design guidelines and uses a Toolbar. As you can read here: The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer. If you would like an application icon (but … Read more

AndroidX ActivityResultContracts package not found / class not found

From the quoted documentation: it is strongly recommended to use the Activity Result APIs introduced in AndroidX Activity 1.2.0-alpha02 and Fragment 1.3.0-alpha02. Neither of those are in your dependencies, at least the portion from your question. You have been manipulating appcompat, not activity or fragment. Add either or both of: implementation “androidx.activity:activity:1.2.0” implementation “androidx.fragment:fragment:1.3.0” (or … Read more

app namespace not found in styles.xml in res folder

You can’t use an app namespace in your style file, and you should refer to style attribute wihtout app namespace in your layout. You can do somenthing like this: <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:id=”@+id/toolbar_show_addresses_simple” style=”@style/toolbar_dark” > Style: <style name=”toolbar_dark” parent=”Widget.AppCompat.Toolbar”> <item name=”android:background”>@color/green</item> <item name=”popupTheme”>@style/ThemeOverlay.AppCompat.Light</item> <item name=”theme”>@style/ThemeOverlay.AppCompat.Dark</item> </style>

Difference between an AppCompat view and a normal Android view

When you are using a Button or an EditText you are actually using AppCompatButton and AppCompatEditText. From the official documentation of the AppCompatEditText. A tint aware EditText. This will automatically be used when you use EditText in your layouts. You should only need to manually use this class when writing custom views