Skip to main content

Posts

Showing posts with the label 2016

Floating Labels : Material Design Tips

From google material design documentation. When the user engages with the text input field, the floating inline labels move to float above the field. How to add? I. In your build.gradle add latest appcompat and design libraries. dependencies { compile 'com.android.support:appcompat-v7:X.X.X'// where X.X.X version compile 'com.android.support:design:X.X.X'// where X.X.X version} II. Make your activity extend android.support.v7.app.AppCompatActivity. publicclassMainActivityextendsAppCompatActivity{...} III. Declare your EditText inside any layout.xml file and wrap it with TextInputLayout. <android.support.design.widget.TextInputLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><EditTextandroid:layout_width="match_parent"android:layout_height="wrap_content"android:hint="@string/Title"/></android.support.design.widget.TextInputLayout>

User Input Errors : Material Design Tips

From google material design documentation. Help users fix input errors as soon as they are detected. Disable the submission of a form if errors are detected, and if detected only after form submission, clearly explain the error and how to fix it. How to add? I. In your build.gradle add latest appcompat and design libraries. dependencies { compile 'com.android.support:appcompat-v7:X.X.X'// where X.X.X version compile 'com.android.support:design:X.X.X'// where X.X.X version} II. Make your activity extend android.support.v7.app.AppCompatActivity. publicclassMainActivityextendsAppCompatActivity{...} III. Declare your EditText inside any layout.xml file and wrap it with TextInputLayout. <android.support.design.widget.TextInputLayoutandroid:id="@+id/inputLayout"android:layout_width="match_parent"android:layout_height="wrap_content"app:errorEnabled="true"><EditTextandroid:layout_width="match_parent"android:lay…

Alerts : Material Design Tips

From Google material design documentation Alerts are urgent interruptions, requiring acknowledgement, that inform the user about a situation. How to add? I. In your build.gradle add latest appcompat library. dependencies { compile 'com.android.support:appcompat-v7:X.X.X'// where X.X.X version} II. Make your activity extend android.support.v7.app.AppCompatActivity. publicclassMainActivityextendsAppCompatActivity{...} III. To create your dialog use android.support.v7.app.AlertDialog.Builder. privatevoid showLocationDialog(){AlertDialog.Builder builder =newAlertDialog.Builder(MainActivity.this); builder.setTitle(getString(R.string.dialog_title)); builder.setMessage(getString(R.string.dialog_message));String positiveText = getString(android.R.str

Cards : Material Design Tips

From Google material design documentation A card is a piece of paper with unique related data that serves as an entry point to more detailed information. For example, a card could contain a photo, text, and a link about a single subject. How to add? I. In your build.gradle include the cardview library: dependencies { compile 'com.android.support:cardview-v7:X.X.X'// where X.X.X version} II. Declare your card inside any layout.xml file and insert views inside it. <android.support.v7.widget.CardViewandroid:layout_width="match_parent"android:layout_height="200dp"><TextViewandroid:text="Hello World!"android:layout_width="wrap_content"android:layout_height="wrap_content"/></android.support.v7.widget.CardView> Use android:clipToPadding="false" on the card parent allows you to prevent posible clips in the outer shadows of the card. How to style? I. Declare your custom style in your styles.xml file. <st…