Posts

Showing posts with the label Material Design

CardView Not Showing Shadow In Android L

Image
Answer : After going through the docs again, I finally found the solution. Just add card_view:cardUseCompatPadding="true" to your CardView and shadows will appear on Lollipop devices. What happens is, the content area in a CardView take different sizes on pre-lollipop and lollipop devices. So in lollipop devices the shadow is actually covered by the card so its not visible. By adding this attribute the content area remains the same across all devices and the shadow becomes visible. My xml code is like : <android.support.v7.widget.CardView android:id="@+id/media_card_view" android:layout_width="match_parent" android:layout_height="130dp" card_view:cardBackgroundColor="@android:color/white" card_view:cardElevation="2dp" card_view:cardUseCompatPadding="true" > ... </android.support.v7.widget.CardView> Do not forget that to draw shadow you must use hardwareAccelerate...

Android Material Design Button Styles

Image
Answer : I will add my answer since I don't use any of the other answers provided. With the Support Library v7, all the styles are actually already defined and ready to use, for the standard buttons, all of these styles are available: style="@style/Widget.AppCompat.Button" style="@style/Widget.AppCompat.Button.Colored" style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless.Colored" Widget.AppCompat.Button : Widget.AppCompat.Button.Colored : Widget.AppCompat.Button.Borderless Widget.AppCompat.Button.Borderless.Colored : To answer the question, the style to use is therefore <Button style="@style/Widget.AppCompat.Button.Colored" ....... ....... ....... android:text="Button"/> How to change the color For the whole app: The color of all the UI controls (not only buttons, but also floating action buttons, checkboxes etc.) is managed by the attribute ...

Change The Icon Size Of AngularJS Material Icons

Answer : By reading the material design in github I found these useful stuff that might help you. /* Rules for sizing the icon. */ .material-icons.md-18 { font-size: 18px; } .material-icons.md-24 { font-size: 24px; } .material-icons.md-36 { font-size: 36px; } .material-icons.md-48 { font-size: 48px; } /* Rules for using icons as black on a light background. */ .material-icons.md-dark { color: rgba(0, 0, 0, 0.54); } .material-icons.md-dark.md-inactive { color: rgba(0, 0, 0, 0.26); } /* Rules for using icons as white on a dark background. */ .material-icons.md-light { color: rgba(255, 255, 255, 1); } .material-icons.md-light.md-inactive { color: rgba(255, 255, 255, 0.3); } From the code above, there you can simply change or override the material css icons. Sample code: <i class="material-icons md-18">face</i> More details here If I'm doing a one-off I usually just add a style= modification to the font-size in the tag. But yes long story short t...

Android "elevation" Not Showing A Shadow

Answer : I've been playing around with shadows on Lollipop for a bit and this is what I've found: It appears that a parent ViewGroup 's bounds cutoff the shadow of its children for some reason; and shadows set with android:elevation are cutoff by the View 's bounds, not the bounds extended through the margin; the right way to get a child view to show shadow is to set padding on the parent and set android:clipToPadding="false" on that parent. Here's my suggestion to you based on what I know: Set your top-level RelativeLayout to have padding equal to the margins you've set on the relative layout that you want to show shadow; set android:clipToPadding="false" on the same RelativeLayout ; Remove the margin from the RelativeLayout that also has elevation set; [EDIT] you may also need to set a non-transparent background color on the child layout that needs elevation. At the end of the day, your top-level relative layout sho...

Angular Material Grid Layout

Image
Answer : I'll give you the basics. In Angular Material (for Angular 2/4) the most commonly used attributes are: fxLayout="row | column" fxLayoutAlign="start | center | end | stretch | space-around | space-between | none" (can accept 2 properties at the same time) fxFlex="number" (can accept numbers from 1 to 100) You can also use postfix as fxLayout.xs and so on to apply rules only for specific resolution. For more info you can look through the docs: https://github.com/angular/flex-layout/wiki/API-Documentation To play around with alignment, you can use the demonstration from Angularjs Material resource (it's totally the same as for Angular Material for Angular 2/4): https://material.angularjs.org/latest/layout/alignment And another one useful link: https://tburleson-layouts-demos.firebaseapp.com/#/docs

Android Support Design TabLayout: Gravity Center And Mode Scrollable

Answer : Tab gravity only effects MODE_FIXED . One possible solution is to set your layout_width to wrap_content and layout_gravity to center_horizontal : <android.support.design.widget.TabLayout android:id="@+id/sliding_tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" app:tabMode="scrollable" /> If the tabs are smaller than the screen width, the TabLayout itself will also be smaller and it will be centered because of the gravity. If the tabs are bigger than the screen width, the TabLayout will match the screen width and scrolling will activate. this is how i did it TabLayout.xml <android.support.design.widget.TabLayout android:id="@+id/tab_layout" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background=...