How to change the background color around a DialogFragment?

I had to set android:windowIsFloating to false and android:windowBackground to my custom color in the dialog style: styles.xml <resources xmlns:android=”http://schemas.android.com/apk/res/android”> <style name=”MyDialog” parent=”@android:style/Theme.Dialog”> <item name=”android:windowFrame”>@null</item> <item name=”android:windowBackground”>@color/orange_transparent</item> <item name=”android:windowIsFloating”>false</item> <item name=”android:windowContentOverlay”>@null</item> <item name=”android:windowTitleStyle”>@null</item> <item name=”android:colorBackgroundCacheHint”>@null</item> <item name=”android:windowAnimationStyle”>@android:style/Animation.Dialog</item> <item name=”android:windowSoftInputMode”>stateUnspecified|adjustPan</item> <item name=”android:gravity”>center</item> </style> </resources> MyDialogFragment public class MyDialogFragment extends DialogFragment { @Override public void onCreate(Bundle savedInstanceState) … Read more

Android CollapsingToolbarLayout Title background

Use a text protection scrim(scroll down a bit). My example assumes the title text is white, so some tweaks may be necessary to optimize for your case. Inside your CollapsingToolbarLayout, add the following after ivBigImage: <View android:layout_width=”match_parent” android:layout_height=”@dimen/sheet_text_scrim_height_top” android:background=”@drawable/scrim_top” app:layout_collapseMode=”pin”/> <View android:layout_width=”match_parent” android:layout_height=”@dimen/sheet_text_scrim_height_bottom” android:layout_gravity=”bottom” android:layout_alignBottom=”@+id/image” android:background=”@drawable/scrim_bottom”/> In your Drawable folder, add: scrim_top.xml <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <gradient … Read more

Difference between android:windowBackground and android:colorBackground?

windowBackground only affects the main window’s background. colorBackground affects not only the background of the main window but also of all components e.g. dialogs unless you override it in the component layout. So both of them change the activity’s background, but the colorBackground changes many more things as well.

Android Toolbar: small title text in landscape mode

I tried to set android:titleTextAppearance of the toolbar but the style wasn’t being applied. Then I realized I’m using the AppCompat theme so I used app:titleTextAppearance and the style is now being applied. It looks like the small letters in landscape are a problem in the built-in AppCompat.Toolbar.Title style itself so I overrode it to … Read more

How to pass AttributeSet when creating view programmatically in android

The constructor with Context and AttributeSet is used when your view is inflated from xml. You shouldn’t use it to create object. You should use constructor with Context as param. AttributeSet is interface and you can create instance of then and implement all method as is shown below: AttributeSet attrs = new AttributeSet(){ @Override public … Read more

How to custom switch button?

However, I might not be taking the best approach, but this is how I have created some Switch like UIs in few of my apps. Here is the code – <RadioGroup android:checkedButton=”@+id/offer” android:id=”@+id/toggle” android:layout_width=”match_parent” android:layout_height=”30dp” android:layout_marginBottom=”@dimen/margin_medium” android:layout_marginLeft=”50dp” android:layout_marginRight=”50dp” android:layout_marginTop=”@dimen/margin_medium” android:background=”@drawable/pink_out_line” android:orientation=”horizontal”> <RadioButton android:layout_marginTop=”1dp” android:layout_marginBottom=”1dp” android:layout_marginLeft=”1dp” android:id=”@+id/search” android:background=”@drawable/toggle_widget_background” android:layout_width=”0dp” android:layout_height=”match_parent” android:layout_weight=”1″ android:button=”@null” android:gravity=”center” android:text=”Search” android:textColor=”@color/white” /> … Read more

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