EzDevInfo.com

material

Material Design Components in regular HTML and CSS, mostly for practicing motion design in the browser.

Android Material Design Button Styles

I'm confused on button styles for material design. I'd like to get colorful raised buttons like in the attached link., like the "force stop" and "uninstall" buttons seen under the usage section. Are there available styles or do I need to define them?

http://www.google.com/design/spec/components/buttons.html#buttons-usage

I couldn't find the default button styles.

Example:

 <Button style="@style/PrimaryButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Calculate"
    android:id="@+id/button3"
    android:layout_below="@+id/editText5"
    android:layout_alignEnd="@+id/editText5"
    android:enabled="true" />

If I try to change the background color of the button by adding

    android:background="@color/primary"

all of the styles go away, such as the touch animation, shadow, rounded corner, etc.


Source: (StackOverflow)

Supporting Android material design

We're redesigning our android app and a question rises considering the upcoming Android L platform with its material style: what are the ways of supporting older devices? Will this new design be acceptable on 4.x devices?


Source: (StackOverflow)

Advertisements

For Android Material support libraries, where can I find CardView and RecyclerView?

I cannot find RecyclerView, Palette or CardView in the support libraries. Emulators responds with a "Class Not Found" error.

How can I fix an error like this?


Source: (StackOverflow)

Angular material layout - expand to fill window

I am attempting to create an Angular material layout. My goal is to create a page where it fills the entire browser window without creating a vertical scroll bar. At the top of the page is a toolbar that consumes 100% of the width of the page. Under the toolbar is a title area that also consumes 100% of the width. Under the title area I would like a nav menu on the left and a client area on the right. My goal is to have both the nav menu and the client area fill vertically the entire browser window.

To give you a visual of what I am trying to accomplish: enter image description here

I have been experimenting with the layout row and column along with the attributes flex and layout-fill. Every other post that I have found indicates that this should be possible with the right combination however the solution has eluded me. I have created a Plunker to demonstrate my problem:

http://plnkr.co/edit/Eva0Cf6KKa0z6I9YsR8t?p=info

Here is my index.html:

<!DOCTYPE html>
<html class="no-js">

<head>
  <meta charset="utf-8">
  <title>adasd</title>
  <meta name="viewport" content="width=device-width">
  <link rel="stylesheet" rel='nofollow' href="//rawgit.com/angular/bower-material/master/angular-material.css">
  <link rel="stylesheet" rel='nofollow' href="nav.css">
  <link rel="stylesheet" rel='nofollow' href="style.css">
</head>
<body ng-app="plunker" ng-controller="MainCtrl">
  <md-toolbar layout="row" class="md-hue-3">
      <div flex="15" layout layout-align="center center" >
        <span>Logo</span>
      </div>
      <div flex="85" layout layout-align="center center" >
        <span>Toolbar Header</span>
      </div>
  </md-toolbar>

  <div flex >
    <div ng-view flex layout-fill></div>
  </div>
  <!-- Angular Material Dependencies -->
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-route.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-animate.min.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-aria.min.js"></script>

  <!-- Angular Material Javascript now available via Google CDN; version 0.6 used here -->
  <script src="//rawgit.com/angular/bower-material/master/angular-material.min.js"></script>

  <script src="app.js"></script>
</body>

</html>

And the main.html (gets displayed in the ng-view):

<div layout="column" flex layout-fill>
  <div layout="row" flex layout-fill>
      <md-whiteframe flex="100" layout layout-align="center center" style="margin-bottom: 16px;height: 60px;">
          <div flex="100"><span id="site-name">Some sort of a title goes here...</span></div>
      </md-whiteframe>
  </div>
  <div layout="row" flex layout-fill>
      <md-sidenav layout-fill class="md-sidenav-left " id="siteMenu" md-component-id=" left" md-is-locked-open="$mdMedia('gt-sm')">
          <md-content layout-fill role="navigation">
              <ul class="docs-menu">
                <li ng-repeat="section in sections" class="parent-list-item">
                      <h2 class="menu-heading" ng-if="section.type === 'heading'" id="heading_{{ section.name | nospace }}">
                          {{section.name}}
                      </h2>
                      <menu-link section="section" ng-if="section.type === 'link'"></menu-link>
                </li>

                  <li ng-repeat="section in menu.sections" class="parent-list-item" ng-class="{'parentActive' : isSectionSelected(section)}">
                      <h2 class="menu-heading" ng-if="section.type === 'heading'" id="heading_{{ section.name | nospace }}">
                          {{section.name}}
                      </h2>
                      <menu-link section="section" ng-if="section.type === 'link'"></menu-link>

                      <menu-toggle section="section" ng-if="section.type === 'toggle'"></menu-toggle>

                      <ul ng-if="section.children" class="menu-nested-list">
                          <li ng-repeat="child in section.children" ng-class="{'childActive' : isSectionSelected(child)}">
                              <menu-toggle section="child"></menu-toggle>
                          </li>
                      </ul>
                  </li>
              </ul>
          </md-content>
      </md-sidenav>

      <md-content layout="row" class="content-wrapper md-padding" flex layout-fill id="content">
        <div flex layout-fill>
          <h2>Home Content</h2>

          <ul>
            <li>Page Content goes here...</li>
            <li>and here...</li>
            <li>and here...</li>
          </ul>
        </div>
      </md-content>
  </div>
</div>

Of course, look at the Plunker to see everything wired together and visually see the problem.

Any help would be greatly appreciated!

PS. I just tested this Plunker on IE 11 and it is having other display issues. But that is for another question another day. It should work correctly on Chrome. Also, the menu will auto hide on windows less than 600px wide. To show the window, make the Plunker display window wider.


Source: (StackOverflow)

What's the difference between Angular Material and Polymer?

I see many material elements both in Polymer and Angular Material. As I know, both of them are google's products about Material design, Are there any relationships between them? Is there any planning about Material for Angular 2.0?


Source: (StackOverflow)

Android Material default colors

I want to have colors for specific card states. I want to be able to reset it to its default.

Where can I find the default material colors from Android? Especally of the Android CardView.

Thanks for help.

Edit:

The Cards have an backgroundcolor (not the images) which is not white. Which color is this? Or is there any method to reset the Backgroundcolor of View-Elements?

Sample of Cards

Sry for bad english.


Source: (StackOverflow)

Displaying background colour through transparent PNG on material?

I'm making a case builder using THREE.js, the basics are i want to be able to change the height/width/length of a box, rotate it around, and also change the background color of the box.

This is it so far: http://design365hosting.co.uk/casebuilder3D/

The dimension changing works, as does the dragging of the box, now i'm working with the background color change.

The way i want this to work is by using transparent PNGs as the faces of the box, and setting background colors so that this background colour shows through the transparent PNG.

This is how I'm currently doing it:

var texture = THREE.ImageUtils.loadTexture("images/crate.png");
materials.push(new THREE.MeshBasicMaterial({color:0xFF0000, map: texture}));

as you can see I set the material to have a background colour of red and overlay the transparent PNG, problem is, three.js seems to ignore the background colour and just show the transparent PNG, meaning no colour shows through.

The expected result should be a red box with the overlayed PNG.

Hope that made sense, can anyone help?


Source: (StackOverflow)

Setting separate material properties for different objects in OpenGL

How can I have separate material properties for different objects drawn in OpenGL? I did the following code, which apparently only shows the later colour:

//************** Object 1 **************
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glColor4f(149.0/255.0, 78.0/255.0, 22.0/255.0, 1.0);
float mat_specular[] = {0.992157, 0.941176, 0.807843, 1.0};
float shininess = 10;

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialf(GL_FRONT, GL_SHININESS, shininess);

glPushMatrix();
glTranslatef(0, 3.0, 0);
drawSphere(0.1, 0.1, 0.1);
glRotatef(10, 1, 0, 0);

glDisable(GL_COLOR_MATERIAL);


//************** Object 2 *****************
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
glColor4f(48.0/255.0, 48.0/255.0, 48.0/255.0, 1.0);
float mat_specular_2[] = {0.992157, 0.941176, 0.807843, 1.0};
float shininess_2 = 10;

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular_2);
glMaterialf(GL_FRONT, GL_SHININESS, shininess_2);

glPushMatrix();
glTranslatef(-0.6, 0.2, 1.6/2.0);
drawSphere(0.1, 0.1, 0.1);
glPopMatrix();

glDisable(GL_COLOR_MATERIAL);

When rendered, the colour set for the Object 2 is used for the entire scene. So the Object 1 is also rendered in Object 2's colour despite having its own colour set already.

How can I have the 2 objects to have separate material properties so that they can be displayed as different colours instead of just one colours in the whole scene?


Source: (StackOverflow)

Three.js texture / image update at runtime

I am trying to change a cube image at run time by selecting an option from Select Form element. When running the code, the image changes after selecting, but the previous cube and image stays in the scene.

How I clear / refresh / update the scene properly when changing the material / image / texture.

<div id = "container"></div>

<form id = "changesForm">
    Cube Image:
    <br>
    <select id = "cubeImage">
        <option value = "random">Random</option>
        <option value = "image1">First Image</option>
        <option value = "Image2">Second Image</option>
    </select>
    <br>
</form>

<script type = "text/javascript">

window.onload = windowLoaded;

function windowLoaded(){
    if (window.addEventListener){
        init();
        animate();
                             //document.getElementById('container').addEventListener('mousemove', containerMouseover, false);
    window.addEventListener( 'resize', onWindowResize, false );
    var cubeImage = document.getElementById('cubeImage');
    cubeImage.addEventListener("change", changeCubeImage, false);
    }
    else if (window.attachEvent){
        //init();
        //animate();
                  //document.getElementById('container').attachEvent('onmousemove', containerMouseover);
        //window.attachEvent( 'onresize', onWindowResize);
    }

function changeCubeImage(e){
    //e.preventDefault();
    var target = e.target;
    cubeImageCheck = target.value;      
    createCube();               
}

// rest code ..... 

function createCube(){
    //image
    var cubeImg;

    switch (cubeImageCheck){
        case 'random': {
           // should load the 2 images random - to do 
            cubeImg = new THREE.ImageUtils.loadTexture("img1.jpg");
           break;
        }
        case 'image1': {
            cubeImg = new THREE.ImageUtils.loadTexture("image1.jpg");
            break;
        }
        case 'image2': {
            cubeImg = new THREE.ImageUtils.loadTexture("image2.jpg");
            break;
       }
}

cubeImg.needsUpdate = true;


// geometry
var cubeGeometry = new THREE.CubeGeometry(200,200,200);;
// material
var cubeMaterial = new THREE.MeshPhongMaterial({
    map: cubeImg, 
    side:THREE.DoubleSide, 
    transparent: true, 
    opacity:1, 
    shading: THREE.SmoothShading, 
    shininess: 90, 
    specular: 0xFFFFFF
});

cubeMaterial.map.needsUpdate = true;

//mesh
cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial);
cubeMesh.needsUpdate = true;
scene.add(cubeMesh);
}

// rest ....

Source: (StackOverflow)

Support Toolbar's custom view not using full width

I'm using support v7's toolbar. I added a custom view, but the custom view doesn't seem to obey "match_parent". It would only stretch as far as the first icon it sees. Does anyone know a fix to this? Or is the toolbar not meant to be used this way?

enter image description here

My code:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    tools:context="com.example.activities.ToolbarActivity"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="100dp"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/light_gray"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:gravity="bottom"
        android:clipChildren="false"
        >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@color/green"
            >


        </RelativeLayout>

    </android.support.v7.widget.Toolbar>

</FrameLayout>

Source: (StackOverflow)

Fixed tabs in new material design android

I've searched stackoverflow and google material design documentation quite a lot but can't find a way how to correctly implement simple fixed tabs in the new material design. I am using appcompat v7 library with toolbar which is great but can't seem to find a way to add tabs to it or simply below it as it is shown heretabs from google website

I've found the SlidingTabsBasic class but that does not meet my requirements as I only use 2 tabs, and they don't fill in the whole horizontal space

Could you please point me into right direction on how to implement those (maybe I have only misunderstood how google wants us to use/implement them).

Much appreciated


Source: (StackOverflow)

Many meshes with the same geometry and material, can I change their colors?

I have a large number (~1000) of THREE.Mesh objects that have been constructed from the same THREE.Geometry and THREE.MeshPhongMaterial (which has a map).

I would like to tint (color) these objects individually.

Naïvely, I tried changing the mesh.material.color property, but changing this property on any of the objects changes the color of all the objects at once. This makes sense, since there is only one material that is shared among all the objects.

My next idea was to create a separate THREE.MeshPhongMaterial for each object. So, now I have a large number of THREE.Mesh objects that been constructed from the same THREE.Geometry, but have individual THREE.MeshPhongMaterials (that share the same texture). This allows me to change the colors individually, but the performance is worse. The chrome profilier shows that the app is spending significant time doing material-things like switching textures.

The material color is just a uniform in the shader. So, updating that uniform should be quite quick.

question: Is there a way to override a material color from the mesh level?

If there was, I believe I could share the material among all my objects and get my performance back, while still changing the colors individually.

[I have tested on v49 and v54, they have identical performance and degredation]

update: I have built a test case, and the performance drop due to this is smaller than I thought it was, but is still measurable.

Here are two links:

In the first case, there are only two materials, in the second case each cube has it's own material. I measure the framerate of the first case to be 53fps on this machine, and the framerate of the second is 46fps. This is about a 15% drop.

In both cases, the color of the material of every cube is changed every frame. In the case with many materials, we actually see each cube getting it's own color, in the case with only two materials, we see them all having the same color (as expected).


Source: (StackOverflow)

How to change programmatically the primary color in Android L

Is there a way to change programmatically the primary colors. I would like to do it in code depending the screen/state of the app.

Currently I can only set the colors in the theme (static) :

    <item name="android:colorPrimary">@color/primary_color</item>
    <item name="android:colorPrimaryDark">@color/dark_color</item>
    <item name="android:colorBackground">@android:color/white</item>
    <item name="android:colorAccent">@color/primary_color</item>
    <item name="android:colorControlHighlight">@color/primary_color</item>

Thanks


Source: (StackOverflow)

Android Theme.AppCompat.Light with Dark Toolbar (for light text)

I have an app using Theme.AppCompat.Light which I need to use so Dialogs have the light theme. But this makes the text in my toolbar black, where I'd rather it be white. I've tried setting the toolbar's specific app:theme to AppCompat.Dark.Actionbar, but no luck... I searched around for a while and couldn't find a specific question and answer to this.

Here's my default AppTheme:

<style name="AppTheme.Parent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/blue</item>
    <item name="colorPrimaryDark">@color/dark_blue</item>
    <item name="colorAccent">@color/pink</item>

    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

Here's my toolbar.xml:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:minHeight="@dimen/abc_action_bar_default_height_material"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

Source: (StackOverflow)

I want to use the android L theme

hello :) I want to change my app so it will have the Material theme, so .. I installed the new adt, updated all on sdk manager, and did this stuff:

I opened a new file - /res/values/styles.xml and used there this code:

    <?xml version="1.0" encoding="utf-8"?>
<resources>
  <!-- your app's theme inherits from the Material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
    <!-- theme customizations -->
  </style>
</resources>

And at the AndroidManifest I used this code:

        <uses-sdk
    android:minSdkVersion="19"
    android:targetSdkVersion="20" />

at the styles.xml I get this error:

"error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'."

what do I need to change?


Source: (StackOverflow)