Merge "Add FAB Sample to Support7Demos" into lmp-mr1-ub-dev
This commit is contained in:
@@ -29,14 +29,20 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
|||||||
android-support-v7-mediarouter \
|
android-support-v7-mediarouter \
|
||||||
android-support-v7-palette \
|
android-support-v7-palette \
|
||||||
android-support-v7-recyclerview \
|
android-support-v7-recyclerview \
|
||||||
android-support-v7-cardview
|
android-support-v7-cardview \
|
||||||
|
android-support-design
|
||||||
LOCAL_RESOURCE_DIR = \
|
LOCAL_RESOURCE_DIR = \
|
||||||
$(LOCAL_PATH)/res \
|
$(LOCAL_PATH)/res \
|
||||||
frameworks/support/v7/appcompat/res \
|
frameworks/support/v7/appcompat/res \
|
||||||
frameworks/support/v7/gridlayout/res \
|
frameworks/support/v7/gridlayout/res \
|
||||||
frameworks/support/v7/mediarouter/res \
|
frameworks/support/v7/mediarouter/res \
|
||||||
frameworks/support/v7/cardview/res
|
frameworks/support/v7/cardview/res \
|
||||||
|
frameworks/support/design/res
|
||||||
LOCAL_AAPT_FLAGS := \
|
LOCAL_AAPT_FLAGS := \
|
||||||
--auto-add-overlay \
|
--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)
|
include $(BUILD_PACKAGE)
|
||||||
|
|||||||
@@ -352,5 +352,14 @@
|
|||||||
android:label="@string/palette"
|
android:label="@string/palette"
|
||||||
android:theme="@style/Theme.AppCompat" />
|
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>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
20
samples/Support7Demos/res/color/card_selector.xml
Normal file
20
samples/Support7Demos/res/color/card_selector.xml
Normal 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>
|
||||||
@@ -132,46 +132,58 @@
|
|||||||
android:text="@string/card_view_bg_color"
|
android:text="@string/card_view_bg_color"
|
||||||
android:layout_below="@id/alpha_label"
|
android:layout_below="@id/alpha_label"
|
||||||
android:layout_alignRight="@id/alpha_label"/>
|
android:layout_alignRight="@id/alpha_label"/>
|
||||||
<RadioGroup
|
|
||||||
android:id="@+id/select_bg_color_radio"
|
<ScrollView
|
||||||
android:layout_toRightOf="@id/color_label"
|
android:layout_width="match_parent"
|
||||||
android:layout_alignTop="@id/color_label"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:layout_below="@id/alpha_seek_bar"
|
||||||
android:layout_below="@id/alpha_seek_bar">
|
android:layout_toRightOf="@id/color_label"
|
||||||
<RadioButton
|
android:layout_alignParentRight="true"
|
||||||
android:id="@+id/def"
|
android:layout_alignTop="@id/color_label">
|
||||||
android:layout_width="40dp"
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/select_bg_color_radio"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/cardview_light_background"
|
android:orientation="horizontal">
|
||||||
android:checked="true"/>
|
<RadioButton
|
||||||
<RadioButton
|
android:id="@+id/def"
|
||||||
android:id="@+id/yellow"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="40dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:background="@color/cardview_light_background"
|
||||||
android:background="@color/card_yellow"/>
|
android:checked="true"/>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/aquatic"
|
android:id="@+id/yellow"
|
||||||
android:layout_width="40dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/card_aquatic"/>
|
android:background="@color/card_yellow"/>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/classic"
|
android:id="@+id/aquatic"
|
||||||
android:layout_width="40dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/card_classic"/>
|
android:background="@color/card_aquatic"/>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/sunbrite"
|
android:id="@+id/classic"
|
||||||
android:layout_width="40dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/card_sunbrite"/>
|
android:background="@color/card_classic"/>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/tropical"
|
android:id="@+id/sunbrite"
|
||||||
android:layout_width="40dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/card_tropical"/>
|
android:background="@color/card_sunbrite"/>
|
||||||
</RadioGroup>
|
<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
|
<RadioGroup
|
||||||
android:id="@+id/select_target_radio"
|
android:id="@+id/select_target_radio"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
@@ -199,7 +211,9 @@
|
|||||||
android:id="@+id/card_view"
|
android:id="@+id/card_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
card_view:cardElevation="10dp">
|
card_view:cardElevation="10dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:layout_margin="8dp">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/info_text"
|
android:id="@+id/info_text"
|
||||||
android:text="@string/card_view"
|
android:text="@string/card_view"
|
||||||
|
|||||||
70
samples/Support7Demos/res/layout/design_fab.xml
Normal file
70
samples/Support7Demos/res/layout/design_fab.xml
Normal 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>
|
||||||
@@ -166,6 +166,7 @@
|
|||||||
<string name="card_view_sample_text">Sample text on right</string>
|
<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_card_view">Resize CardView</string>
|
||||||
<string name="card_view_resize_content">Resize Content</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">Palette</string>
|
||||||
<string name="palette_all_colors">Full color 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="sorted_list_activity">Sorted List</string>
|
||||||
<string name="add_new_item">Add New Item</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>
|
</resources>
|
||||||
|
|||||||
@@ -33,4 +33,10 @@
|
|||||||
<item name="android:minHeight">35dp</item>
|
<item name="android:minHeight">35dp</item>
|
||||||
</style>
|
</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>
|
</resources>
|
||||||
@@ -16,8 +16,6 @@
|
|||||||
package com.example.android.supportv7.view;
|
package com.example.android.supportv7.view;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
@@ -30,8 +28,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.example.android.supportv7.R;
|
import com.example.android.supportv7.R;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class CardViewActivity extends Activity {
|
public class CardViewActivity extends Activity {
|
||||||
|
|
||||||
CardView mCardView;
|
CardView mCardView;
|
||||||
@@ -182,6 +178,8 @@ public class CardViewActivity extends Activity {
|
|||||||
return R.color.card_sunbrite;
|
return R.color.card_sunbrite;
|
||||||
case R.id.tropical:
|
case R.id.tropical:
|
||||||
return R.color.card_tropical;
|
return R.color.card_tropical;
|
||||||
|
case R.id.selector:
|
||||||
|
return R.color.card_selector;
|
||||||
default:
|
default:
|
||||||
return R.color.cardview_light_background;
|
return R.color.cardview_light_background;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user