Merge "Add FAB Sample to Support7Demos" into lmp-mr1-ub-dev

This commit is contained in:
Chris Banes
2015-01-28 09:44:56 +00:00
committed by Android (Google) Code Review
9 changed files with 214 additions and 46 deletions

View File

@@ -29,14 +29,20 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v7-mediarouter \
android-support-v7-palette \
android-support-v7-recyclerview \
android-support-v7-cardview
android-support-v7-cardview \
android-support-design
LOCAL_RESOURCE_DIR = \
$(LOCAL_PATH)/res \
frameworks/support/v7/appcompat/res \
frameworks/support/v7/gridlayout/res \
frameworks/support/v7/mediarouter/res \
frameworks/support/v7/cardview/res
frameworks/support/v7/cardview/res \
frameworks/support/design/res
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.v7.cardview:android.support.v7.appcompat:android.support.v7.gridlayout:android.support.v7.mediarouter
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.cardview \
--extra-packages android.support.v7.gridlayout \
--extra-packages android.support.v7.mediarouter \
--extra-packages android.support.design
include $(BUILD_PACKAGE)

View File

@@ -352,5 +352,14 @@
android:label="@string/palette"
android:theme="@style/Theme.AppCompat" />
<activity android:name=".widget.FloatingActionButtonUsage"
android:label="@string/design_fab"
android:theme="@style/Theme.FAB">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,20 @@
<?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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="@color/card_tropical"/>
<item android:state_pressed="true" android:color="@color/card_tropical"/>
<item android:color="@color/card_yellow"/>
</selector>

View File

@@ -132,46 +132,58 @@
android:text="@string/card_view_bg_color"
android:layout_below="@id/alpha_label"
android:layout_alignRight="@id/alpha_label"/>
<RadioGroup
android:id="@+id/select_bg_color_radio"
android:layout_toRightOf="@id/color_label"
android:layout_alignTop="@id/color_label"
android:layout_width="fill_parent"
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/alpha_seek_bar">
<RadioButton
android:id="@+id/def"
android:layout_width="40dp"
android:layout_below="@id/alpha_seek_bar"
android:layout_toRightOf="@id/color_label"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/color_label">
<RadioGroup
android:id="@+id/select_bg_color_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/cardview_light_background"
android:checked="true"/>
<RadioButton
android:id="@+id/yellow"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:background="@color/card_yellow"/>
<RadioButton
android:id="@+id/aquatic"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:background="@color/card_aquatic"/>
<RadioButton
android:id="@+id/classic"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:background="@color/card_classic"/>
<RadioButton
android:id="@+id/sunbrite"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:background="@color/card_sunbrite"/>
<RadioButton
android:id="@+id/tropical"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:background="@color/card_tropical"/>
</RadioGroup>
android:orientation="horizontal">
<RadioButton
android:id="@+id/def"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/cardview_light_background"
android:checked="true"/>
<RadioButton
android:id="@+id/yellow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/card_yellow"/>
<RadioButton
android:id="@+id/aquatic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/card_aquatic"/>
<RadioButton
android:id="@+id/classic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/card_classic"/>
<RadioButton
android:id="@+id/sunbrite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/card_sunbrite"/>
<RadioButton
android:id="@+id/tropical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/card_tropical"/>
<RadioButton
android:id="@+id/selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cardview_background_selector_label"/>
</RadioGroup>
</ScrollView>
<RadioGroup
android:id="@+id/select_target_radio"
android:layout_width="fill_parent"
@@ -199,7 +211,9 @@
android:id="@+id/card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardElevation="10dp">
card_view:cardElevation="10dp"
android:clickable="true"
android:layout_margin="8dp">
<TextView
android:id="@+id/info_text"
android:text="@string/card_view"

View File

@@ -0,0 +1,70 @@
<?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.
-->
<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">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical"
android:clipToPadding="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:text="@string/fab_size_normal"
android:layout_margin="16dp"/>
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"
android:clickable="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:text="@string/fab_size_mini" />
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="16dp"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha"
android:clickable="true"
app:fabSize="mini" />
</LinearLayout>
</FrameLayout>

View File

@@ -166,6 +166,7 @@
<string name="card_view_sample_text">Sample text on right</string>
<string name="card_view_resize_card_view">Resize CardView</string>
<string name="card_view_resize_content">Resize Content</string>
<string name="cardview_background_selector_label">Selector</string>
<string name="palette">Palette</string>
<string name="palette_all_colors">Full color palette</string>
@@ -173,4 +174,8 @@
<string name="sorted_list_activity">Sorted List</string>
<string name="add_new_item">Add New Item</string>
<string name="design_fab">Design/Floating Action Button</string>
<string name="fab_size_normal">Normal size</string>
<string name="fab_size_mini">Mini size</string>
</resources>

View File

@@ -33,4 +33,10 @@
<item name="android:minHeight">35dp</item>
</style>
<style name="Theme.FAB" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#ff00bcd4</item>
<item name="colorPrimaryDark">#00838f</item>
<item name="colorAccent">#ff0000</item>
</style>
</resources>

View File

@@ -16,8 +16,6 @@
package com.example.android.supportv7.view;
import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.ViewCompat;
@@ -30,8 +28,6 @@ import android.widget.TextView;
import com.example.android.supportv7.R;
import java.lang.reflect.Field;
public class CardViewActivity extends Activity {
CardView mCardView;
@@ -182,6 +178,8 @@ public class CardViewActivity extends Activity {
return R.color.card_sunbrite;
case R.id.tropical:
return R.color.card_tropical;
case R.id.selector:
return R.color.card_selector;
default:
return R.color.cardview_light_background;
}

View File

@@ -0,0 +1,40 @@
/*
* 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.supportv7.widget;
import com.example.android.supportv7.R;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
/**
* This demonstrates idiomatic usage of the Floating Action Button
*/
public class FloatingActionButtonUsage extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.design_fab);
// Retrieve the Toolbar from our content view, and set it as the action bar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
}