Force BottomNavigationView item labels to be singleLine.

- Set BottomNavigationView item labels to be single line.
- Update BottomNavigationViewUsage to demo OnNavigationItemSelectedListener
  usage.

Bug: 32414896
Test: ran SupportDesignDemos
Change-Id: I701a25826f5f2e28b4262dc0526b151ec5a65514
diff --git a/design/res/layout/design_bottom_navigation_item.xml b/design/res/layout/design_bottom_navigation_item.xml
index cc7bb5f..67df838 100644
--- a/design/res/layout/design_bottom_navigation_item.xml
+++ b/design/res/layout/design_bottom_navigation_item.xml
@@ -34,6 +34,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textSize="@dimen/design_bottom_navigation_text_size"
+            android:singleLine="true"
             android:duplicateParentState="true" />
         <TextView
             android:id="@+id/largeLabel"
@@ -41,6 +42,7 @@
             android:layout_height="wrap_content"
             android:visibility="invisible"
             android:textSize="@dimen/design_bottom_navigation_active_text_size"
+            android:singleLine="true"
             android:duplicateParentState="true" />
     </android.support.design.internal.BaselineLayout>
 </merge>
\ No newline at end of file
diff --git a/samples/SupportDesignDemos/res/layout/design_bottom_navigation_view.xml b/samples/SupportDesignDemos/res/layout/design_bottom_navigation_view.xml
index 83e7314..c868430 100644
--- a/samples/SupportDesignDemos/res/layout/design_bottom_navigation_view.xml
+++ b/samples/SupportDesignDemos/res/layout/design_bottom_navigation_view.xml
@@ -14,46 +14,56 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<RelativeLayout
+<FrameLayout
         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">
 
-    <Button
-            android:id="@+id/button_disable"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/bottomnavigation_disable"/>
+    <ScrollView android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginBottom="56dp">
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+            <Button
+                android:id="@+id/button_disable"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/bottomnavigation_disable"/>
+            <Button
+                android:id="@+id/button_add"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/bottomnavigation_add"
+                android:layout_below="@+id/button_disable"/>
 
-    <Button
-        android:id="@+id/button_add"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/bottomnavigation_add"
-        android:layout_below="@+id/button_disable"/>
+            <Button
+                android:id="@+id/button_remove"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/bottomnavigation_remove"
+                android:layout_below="@+id/button_add"/>
 
-    <Button
-        android:id="@+id/button_remove"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/bottomnavigation_remove"
-        android:layout_below="@+id/button_add"/>
+            <Button
+                android:id="@+id/button_tint"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/bottomnavigation_tint"
+                android:layout_below="@+id/button_remove"/>
 
-    <Button
-        android:id="@+id/button_tint"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/bottomnavigation_tint"
-        android:layout_below="@+id/button_remove"/>
-
+            <TextView
+                android:id="@+id/selected_item"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@+id/button_tint"/>
+        </RelativeLayout>
+    </ScrollView>
     <android.support.design.widget.BottomNavigationView
             android:id="@+id/bottom_navigation"
             android:layout_width="match_parent"
             android:layout_height="56dp"
             android:layout_gravity="bottom"
             android:background="#eee"
-            android:layout_alignParentBottom="true"
             app:menu="@menu/sample_bottom_menu"/>
-
-</RelativeLayout>
+</FrameLayout>
diff --git a/samples/SupportDesignDemos/res/menu/sample_bottom_menu.xml b/samples/SupportDesignDemos/res/menu/sample_bottom_menu.xml
index 4294f80..d6d4761 100644
--- a/samples/SupportDesignDemos/res/menu/sample_bottom_menu.xml
+++ b/samples/SupportDesignDemos/res/menu/sample_bottom_menu.xml
@@ -20,7 +20,7 @@
     <item android:id="@+id/action_settings"
           android:title="@string/menu_settings"
           android:icon="@drawable/ic_add"/>
-    <item android:id="@+id/action_navigation"
+    <item android:id="@+id/action_music"
           android:title="@string/tab_text"
           android:icon="@drawable/ic_action_navigation_menu"/>
 </menu>
\ No newline at end of file
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomNavigationViewUsage.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomNavigationViewUsage.java
index 72b50db..4cfef7a 100644
--- a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomNavigationViewUsage.java
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/BottomNavigationViewUsage.java
@@ -18,11 +18,13 @@
 
 import android.content.res.ColorStateList;
 import android.os.Bundle;
+import android.support.annotation.NonNull;
 import android.support.design.widget.BottomNavigationView;
 import android.support.v7.app.AppCompatActivity;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.Button;
+import android.widget.TextView;
 
 import com.example.android.support.design.R;
 
@@ -74,5 +76,26 @@
                 }
             }
         });
+        final TextView selectedItem = (TextView) findViewById(R.id.selected_item);
+        bottom.setOnNavigationItemSelectedListener(
+                new BottomNavigationView.OnNavigationItemSelectedListener() {
+                    @Override
+                    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+                        switch (item.getItemId()) {
+                            case R.id.action_search:
+                                selectedItem.setText("Entering searching mode");
+                                break;
+                            case R.id.action_settings:
+                                selectedItem.setText("Entering settings!?!");
+                                break;
+                            case R.id.action_music:
+                                selectedItem.setText("Play some music");
+                                break;
+                            default:
+                                selectedItem.setText("Selected " + item.getTitle());
+                        }
+                        return false;
+                    }
+                });
     }
 }