How can I style an Android Switch?

You can define the drawables that are used for the background, and the switcher part like this: <Switch android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:thumb=”@drawable/switch_thumb” android:track=”@drawable/switch_bg” /> Now you need to create a selector that defines the different states for the switcher drawable. Here the copies from the Android sources: <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_enabled=”false” android:drawable=”@drawable/switch_thumb_disabled_holo_light” /> <item android:state_pressed=”true” android:drawable=”@drawable/switch_thumb_pressed_holo_light” … Read more

How to hide status bar in Android

Write this in your Activity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); } Check Doc here : https://developer.android.com/training/system-ui/status.html and your app will go fullscreen. no status bar, no title bar. 🙂

Set theme for a Fragment

Setting Theme in manifest is usually used for Activity. If you want to set Theme for Fragment, add next code in the onGetLayoutInflater() of the Fragment: override fun onGetLayoutInflater(savedInstanceState: Bundle?): LayoutInflater { val inflater = super.onGetLayoutInflater(savedInstanceState) val contextThemeWrapper: Context = ContextThemeWrapper(requireContext(), R.style.yourCustomTheme) return inflater.cloneInContext(contextThemeWrapper) }

How to set Toolbar text and back arrow color

Chances are you are extending from the wrong parent. If not, you can try adding the style to the toolbar layout directly, if you want to override the theme’s settings. In your toolbar layout: <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:minHeight=”?attr/actionBarSize” app:theme=”@style/ToolBarStyle” app:popupTheme=”@style/ToolBarPopupStyle” android:background=”@color/actionbar_color” /> In your styles: <!– ToolBar –> <style name=”ToolBarStyle” parent=”Theme.AppCompat”> <item … Read more

Using App namespace in style

For app namespace you don’t need to specify app:<property name>. Just <property name> is enough. For example <style name=”FabStyle” parent=”Widget.Design.FloatingActionButton”> <item name=”android:layout_width”>wrap_content</item> <item name=”android:layout_height”>wrap_content</item> <item name=”android:layout_margin”>16dp</item> <item name=”backgroundTint”>@color/accent</item> <item name=”layout_anchorGravity”>end|bottom</item> </style> And for layout_anchorGravity you need to set it in XML file where you are defining Floating action button.

Get color value programmatically when it’s a reference (theme)

This should do the job: TypedValue typedValue = new TypedValue(); Theme theme = context.getTheme(); theme.resolveAttribute(R.attr.theme_color, typedValue, true); @ColorInt int color = typedValue.data; Also make sure to apply the theme to your Activity before calling this code. Either use: android:theme=”@style/Theme.BlueTheme” in your manifest or call (before you call setContentView(int)): setTheme(R.style.Theme_BlueTheme) in onCreate(). I’ve tested it with … Read more

How do I change the background color of the ActionBar of an ActionBarActivity using XML?

As per documentation – “You can control the behaviors and visibility of the action bar with the ActionBar APIs, which were added in Android 3.0 (API level 11).” So, ActionBar will not work for your target environment which is at API level 10 (Android 2.3.3). Just in case, if you target for minimum API level … Read more

Full Screen Theme for AppCompat

When you use Theme.AppCompat in your application you can use FullScreenTheme by adding the code below to styles. <style name=”Theme.AppCompat.Light.NoActionBar.FullScreen” parent=”@style/Theme.AppCompat.Light.NoActionBar”> <item name=”android:windowNoTitle”>true</item> <item name=”android:windowActionBar”>false</item> <item name=”android:windowFullscreen”>true</item> <item name=”android:windowContentOverlay”>@null</item> </style> and also mention in your manifest file. <activity android:name=”.activities.FullViewActivity” android:theme=”@style/Theme.AppCompat.Light.NoActionBar.FullScreen” />

Can’t Find Theme.AppCompat.Light for New Android ActionBar Support

You need to do next: File->Import (android-sdk\extras\android\support\v7). Choose “AppCompat” Project-> properties->Android. In the section library “Add” and choose “AppCompat” That is all! Note: if you are using “android:showAsAction” in menu item, you need to change prefix android as in the example http://developer.android.com/guide/topics/ui/actionbar.html

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