Merge "TextInputLayout and Snackbar demos" into lmp-mr1-ub-dev
This commit is contained in:
@@ -54,5 +54,31 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".widget.TextInputLayoutUsage"
|
||||||
|
android:label="@string/design_text_input"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".widget.SnackbarUsage"
|
||||||
|
android:label="@string/design_snackbar_basic"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="com.example.android.support.design.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".widget.SnackbarWithFloatingActionButton"
|
||||||
|
android:label="@string/design_snackbar_fab"
|
||||||
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="com.example.android.support.design.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
61
samples/SupportDesignDemos/res/layout/design_snackbar.xml
Normal file
61
samples/SupportDesignDemos/res/layout/design_snackbar.xml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/content_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_short"
|
||||||
|
android:onClick="showShort"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_short_action"
|
||||||
|
android:onClick="showAction"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_long"
|
||||||
|
android:onClick="showLong"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_long_action"
|
||||||
|
android:onClick="showLongAction"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_long_long_action"
|
||||||
|
android:onClick="showLongLongAction"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/content_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_short"
|
||||||
|
android:onClick="showShort"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_short_action"
|
||||||
|
android:onClick="showAction"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_long"
|
||||||
|
android:onClick="showLong"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_long_action"
|
||||||
|
android:onClick="showLongAction"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/snackbar_show_long_long_action"
|
||||||
|
android:onClick="showLongLongAction"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"
|
||||||
|
android:clickable="true"/>
|
||||||
|
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
66
samples/SupportDesignDemos/res/layout/design_text_input.xml
Normal file
66
samples/SupportDesignDemos/res/layout/design_text_input.xml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:id="@+id/input_username"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:errorEnabled="true">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edit_username"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/form_username"/>
|
||||||
|
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:id="@+id/input_email"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
app:errorEnabled="true">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edit_email"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/form_email"/>
|
||||||
|
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/show_error"
|
||||||
|
android:onClick="showError"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/clear_error"
|
||||||
|
android:onClick="clearError"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
<string name="design_fab">Floating Action Button/Basic</string>
|
<string name="design_fab">Floating Action Button/Basic</string>
|
||||||
<string name="design_tabs_basic">TabLayout/Usage</string>
|
<string name="design_tabs_basic">TabLayout/Usage</string>
|
||||||
|
<string name="design_text_input">Text Input</string>
|
||||||
|
|
||||||
<string name="fab_size_normal">Normal size</string>
|
<string name="fab_size_normal">Normal size</string>
|
||||||
<string name="fab_size_mini">Mini size</string>
|
<string name="fab_size_mini">Mini size</string>
|
||||||
|
|
||||||
@@ -30,4 +32,17 @@
|
|||||||
<string name="add_tab">Add tab</string>
|
<string name="add_tab">Add tab</string>
|
||||||
<string name="remove_tab">Remove tab</string>
|
<string name="remove_tab">Remove tab</string>
|
||||||
|
|
||||||
|
<string name="form_username">Username</string>
|
||||||
|
<string name="form_email">Email address</string>
|
||||||
|
<string name="show_error">Show error</string>
|
||||||
|
<string name="clear_error">Clear error</string>
|
||||||
|
|
||||||
|
<string name="design_snackbar_basic">Snackbar/Usage</string>
|
||||||
|
<string name="design_snackbar_fab">Snackbar/Coordinated with FAB</string>
|
||||||
|
<string name="snackbar_show_short">Snackbar (short message)</string>
|
||||||
|
<string name="snackbar_show_long">Snackbar (long message)</string>
|
||||||
|
<string name="snackbar_show_short_action">Show (short message + action)</string>
|
||||||
|
<string name="snackbar_show_long_action">Show (long message + action)</string>
|
||||||
|
<string name="snackbar_show_long_long_action">Show (long message + long action)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.android.support.design.widget;
|
||||||
|
|
||||||
|
import com.example.android.support.design.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This demonstrates idiomatic usage of the Floating Action Button
|
||||||
|
*/
|
||||||
|
public class SnackbarUsage extends AppCompatActivity {
|
||||||
|
|
||||||
|
private ViewGroup mContentView;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(getLayoutId());
|
||||||
|
|
||||||
|
mContentView = (ViewGroup) findViewById(R.id.content_view);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getLayoutId() {
|
||||||
|
return R.layout.design_snackbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showShort(View view) {
|
||||||
|
Snackbar.make(mContentView, "Short snackbar message", Snackbar.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showAction(View view) {
|
||||||
|
Snackbar.make(mContentView, "Short snackbar message", Snackbar.LENGTH_SHORT)
|
||||||
|
.setAction("Action", new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Toast.makeText(SnackbarUsage.this, "Snackbar Action pressed",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showLong(View view) {
|
||||||
|
Snackbar.make(mContentView, "Long snackbar message which wraps onto another line and"
|
||||||
|
+ "makes the Snackbar taller", Snackbar.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showLongAction(View view) {
|
||||||
|
Snackbar.make(mContentView, "Long snackbar message which wraps onto another line and"
|
||||||
|
+ "makes the Snackbar taller", Snackbar.LENGTH_SHORT)
|
||||||
|
.setAction("Action", new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Toast.makeText(SnackbarUsage.this, "Snackbar Action pressed",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showLongLongAction(View view) {
|
||||||
|
Snackbar.make(mContentView, "Long snackbar message which wraps onto another line and"
|
||||||
|
+ "makes the Snackbar taller", Snackbar.LENGTH_SHORT)
|
||||||
|
.setAction("Action which wraps", new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Toast.makeText(SnackbarUsage.this, "Snackbar Action pressed",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.android.support.design.widget;
|
||||||
|
|
||||||
|
import com.example.android.support.design.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This demonstrates idiomatic usage of the Floating Action Button
|
||||||
|
*/
|
||||||
|
public class SnackbarWithFloatingActionButton extends SnackbarUsage {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId() {
|
||||||
|
return R.layout.design_snackbar_with_fab;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.android.support.design.widget;
|
||||||
|
|
||||||
|
import com.example.android.support.design.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.TextInputLayout;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This demonstrates idiomatic usage of {@code TextInputLayout}
|
||||||
|
*/
|
||||||
|
public class TextInputLayoutUsage extends AppCompatActivity {
|
||||||
|
|
||||||
|
private TextInputLayout mUsernameInputLayout;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.design_text_input);
|
||||||
|
|
||||||
|
mUsernameInputLayout = (TextInputLayout) findViewById(R.id.input_username);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showError(View view) {
|
||||||
|
mUsernameInputLayout.setError("Some unknown error has occurred");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearError(View view) {
|
||||||
|
mUsernameInputLayout.setError(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user