How to use Holo.Light theme, and fall back to ‘Light’ on pre-honeycomb devices?

You have to create a custom theme and save it in some directories to finally set this theme as the default one for the app First, in values add a themes.xml like this: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <style name=”MyAppTheme” parent=”@android:style/Theme.Light.NoTitleBar”> <!– Any customizations for your app running on pre-3.0 devices here –> </style> </resources> Then, … Read more

How to: Define theme (style) item for custom widget

Yes, there’s one way: Suppose you have a declaration of attributes for your widget (in attrs.xml): <declare-styleable name=”CustomImageButton”> <attr name=”customAttr” format=”string”/> </declare-styleable> Declare an attribute you will use for a style reference (in attrs.xml): <declare-styleable name=”CustomTheme”> <attr name=”customImageButtonStyle” format=”reference”/> </declare-styleable> Declare a set of default attribute values for the widget (in styles.xml): <style name=”Widget.ImageButton.Custom” parent=”android:style/Widget.ImageButton”> … Read more

Can someone explain the attr?

The ?attr/menuIconCamera value means that an icon from menuIconCamera attribute of the current theme will be used. There must be a drawable assigned to the menuIconCamera attribute somewhere in the themes.xml file. If there’re two themes with different values of this attribute then actual icon will depend on a theme which is currently used. The … Read more

UnsupportedOperationException: Can’t convert to dimension: type=0x1

After 2 days I found the solution; from the layout as defined in my question, I have a Spinner which is bound with a custom TextView: <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/listTextViewSpinner” … android:textSize=”@dimen/spinner_list_item_text_size” … /> Here, I have an extracted dimension resource: @dimen/spinner_list_item_text_size. This has been defined in dimens.xml in the following directories: values-sw600dp … Read more

How to reference style attributes from a drawable?

In my experience it is not possible to reference an attribute in an XML drawable. In order to make your theme you need to: Create one XML drawable per theme. Include the needed color into you drawable directly with the @color tag or #RGB format. Make an attribute for your drawable in attrs.xml. <?xml version=”1.0″ … 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

How to center align the ActionBar title in Android?

To have a centered title in ABS (if you want to have this in the default ActionBar, just remove the “support” in the method names), you could just do this: In your Activity, in your onCreate() method: getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getSupportActionBar().setCustomView(R.layout.abs_layout); abs_layout: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center” android:orientation=”vertical”> <androidx.appcompat.widget.AppCompatTextView android:id=”@+id/tvTitle” style=”@style/TextAppearance.AppCompat.Widget.ActionBar.Title” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:gravity=”center” … Read more

When should one use Theme.AppCompat vs ThemeOverlay.AppCompat?

Theme.AppCompat is used to set the global theme for the entire app. ThemeOverlay.AppCompat is used to override (or “overlay”) that theme for specific views, especially the Toolbar. Let’s look at an example for why this is necessary. App themes with an ActionBar The ActionBar is normally shown in an app. I can choose it’s color … Read more

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