Setting Elevation in XML on AppCompat CardView on Android 5.0

It looks like a margin/padding problem, try to set the cardUseCompatPadding attribute to true. E.g.: <android.support.v7.widget.CardView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:card_view=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_margin=”6dp” card_view:cardUseCompatPadding=”true” card_view:cardElevation=”4dp” card_view:cardCornerRadius=”3dp”> Explanation from Android doc : CardView adds additional padding to draw shadows on platforms before L. This may cause Cards to have different sizes between L and before L. If you … Read more

How do I set a different theme for a Spinner’s dropdown?

Android M New in Android 6.0, Spinner now has the android:popupTheme parameter which allows you to set the theme used for the popup (dropdown). You can use it as so: <Spinner android:layout_height=”wrap_content” android:layout_width=”match_parent” android:popupTheme=”@android:style/ThemeOverlay.Material.Light” /> That will work on devices running API level 23+, but not on devices running a lower version of Android. AppCompat … Read more

How do I style appcompat-v7 Toolbar like Theme.AppCompat.Light.DarkActionBar?

The recommended way to style the Toolbar for a Light.DarkActionBar clone would be to use Theme.AppCompat.Light.DarkActionbar as parent/app theme and add the following attributes to the style to hide the default ActionBar: <style name=”AppTheme” parent=”Theme.AppCompat.Light.DarkActionBar”> <item name=”windowActionBar”>false</item> <item name=”windowNoTitle”>true</item> </style> Then use the following as your Toolbar: <android.support.design.widget.AppBarLayout 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” … Read more

MenuItem tinting on AppCompat Toolbar

After the new Support library v22.1, you can use something similar to this: @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_home, menu); Drawable drawable = menu.findItem(R.id.action_clear).getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, ContextCompat.getColor(this,R.color.textColorPrimary)); menu.findItem(R.id.action_clear).setIcon(drawable); return true; }

AppCompatActivity.onCreate can only be called from within the same library group

As previous responses highlighted, it is bug. I recommend not to disable the specific lint warning project-wide, but for that method only. Annotate your method as follows: @SuppressLint(“RestrictedApi”) @Override public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); //your code here }

CardView Corner Radius

Unless you try to extend the Android CardView class, you cannot customize that attribute from XML. Nonetheless, there is a way of obtaining that effect. Place a CardView inside another CardView and apply a transparent background to your outer CardView and remove its corner radius (“cornerRadios = 0dp”). Your inner CardView will have a cornerRadius … Read more

How can I modify ripple color when using ?attr/selectableItemBackground as background?

Finally I find the solution: instead of using android:colorControlHighlight directly in theme SelectableItemBackground, I should write another style: <style name=”SelectableItemTheme”> <item name=”colorControlHighlight”>@color/ripple_color</item> </style> Then: <style name=”SelectableItemBackground”> <item name=”android:theme”>@style/SelectableItemTheme</item> <item name=”android:background”>?attr/selectableItemBackground</item> </style> Finally add style=”@style/SelectableItemBackground” to View in layout.xml. UPDATED ON 2016/8/26 After N’s release, I found that sometimes we cannot use this method to set … Read more

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