Switched from using ActionBar to using Toolbar
This commit is contained in:
@@ -22,7 +22,7 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile 'com.github.bumptech.glide:glide:3.5.2'
|
compile 'com.github.bumptech.glide:glide:3.5.2'
|
||||||
compile 'com.android.support:appcompat-v7:21.0.2'
|
compile 'com.android.support:appcompat-v7:22.1.0'
|
||||||
compile 'com.android.support:support-annotations:22.0.0'
|
compile 'com.android.support:support-annotations:22.1.0'
|
||||||
compile 'com.google.android.gms:play-services-gcm:7.0.0'
|
compile 'com.google.android.gms:play-services-gcm:7.0.0'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@
|
|||||||
android:supportsRtl="true">
|
android:supportsRtl="true">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name">
|
||||||
android:theme="@style/ForecastTheme" >
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
|||||||
@@ -18,17 +18,23 @@ package com.example.android.sunshine.app;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
|
||||||
public class DetailActivity extends ActionBarActivity {
|
public class DetailActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_detail);
|
setContentView(R.layout.activity_detail);
|
||||||
|
|
||||||
|
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
// Create the detail fragment and add it to the activity
|
// Create the detail fragment and add it to the activity
|
||||||
// using a fragment transaction.
|
// using a fragment transaction.
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ import android.content.pm.PackageManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -36,7 +37,7 @@ import com.google.android.gms.gcm.GoogleCloudMessaging;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class MainActivity extends ActionBarActivity implements ForecastFragment.Callback {
|
public class MainActivity extends AppCompatActivity implements ForecastFragment.Callback {
|
||||||
|
|
||||||
private final String LOG_TAG = MainActivity.class.getSimpleName();
|
private final String LOG_TAG = MainActivity.class.getSimpleName();
|
||||||
private static final String DETAILFRAGMENT_TAG = "DFTAG";
|
private static final String DETAILFRAGMENT_TAG = "DFTAG";
|
||||||
@@ -60,6 +61,10 @@ public class MainActivity extends ActionBarActivity implements ForecastFragment.
|
|||||||
mLocation = Utility.getPreferredLocation(this);
|
mLocation = Utility.getPreferredLocation(this);
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||||
|
|
||||||
if (findViewById(R.id.weather_detail_container) != null) {
|
if (findViewById(R.id.weather_detail_container) != null) {
|
||||||
// The detail container view will be present only in the large-screen layouts
|
// The detail container view will be present only in the large-screen layouts
|
||||||
// (res/layout-sw600dp). If this view is present, then the activity should be
|
// (res/layout-sw600dp). If this view is present, then the activity should be
|
||||||
|
|||||||
@@ -17,27 +17,46 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:baselineAligned="false"
|
android:orientation="vertical">
|
||||||
android:divider="?android:attr/dividerHorizontal"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
tools:context="com.example.android.sunshine.app.MainActivity">
|
|
||||||
|
|
||||||
<!--
|
<android.support.v7.widget.Toolbar
|
||||||
This layout is a two-pane layout for the Items master/detail flow.
|
android:id="@+id/toolbar"
|
||||||
-->
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:src="@drawable/ic_logo"
|
||||||
|
android:scaleType="center"/>
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
<fragment
|
<LinearLayout
|
||||||
android:id="@+id/fragment_forecast"
|
android:layout_width="match_parent"
|
||||||
android:name="com.example.android.sunshine.app.ForecastFragment"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="2"
|
android:baselineAligned="false"
|
||||||
tools:layout="@android:layout/list_content" />
|
android:divider="?android:attr/dividerHorizontal"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
tools:context="com.example.android.sunshine.app.MainActivity">
|
||||||
|
|
||||||
<FrameLayout
|
<!--
|
||||||
android:id="@+id/weather_detail_container"
|
This layout is a two-pane layout for the Items master/detail flow.
|
||||||
android:layout_width="0dp"
|
-->
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="4" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
<fragment
|
||||||
|
android:id="@+id/fragment_forecast"
|
||||||
|
android:name="com.example.android.sunshine.app.ForecastFragment"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="2"
|
||||||
|
tools:layout="@android:layout/list_content" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/weather_detail_container"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="4" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
@@ -13,10 +13,23 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/weather_detail_container"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
tools:context="com.example.android.sunshine.app.DetailActivity"
|
android:orientation="vertical">
|
||||||
tools:ignore="MergeRootFrame" />
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||||
|
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/weather_detail_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.example.android.sunshine.app.DetailActivity"
|
||||||
|
tools:ignore="MergeRootFrame" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -13,11 +13,30 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/fragment_forecast"
|
|
||||||
android:name="com.example.android.sunshine.app.ForecastFragment"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
tools:context="com.example.android.sunshine.app.ForecastFragment"
|
android:orientation="vertical">
|
||||||
tools:layout="@android:layout/list_content" />
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:src="@drawable/ic_logo"
|
||||||
|
android:scaleType="center"/>
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/fragment_forecast"
|
||||||
|
android:name="com.example.android.sunshine.app.ForecastFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.example.android.sunshine.app.ForecastFragment"
|
||||||
|
tools:layout="@android:layout/list_content" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -16,25 +16,22 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
|
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
|
||||||
<item name="colorPrimary">@color/primary</item>
|
<item name="colorPrimary">@color/primary</item>
|
||||||
<item name="colorPrimaryDark">@color/primary_dark</item>
|
<item name="colorPrimaryDark">@color/primary_dark</item>
|
||||||
<item name="colorAccent">@color/accent</item>
|
<item name="colorAccent">@color/accent</item>
|
||||||
|
<item name="toolbarStyle">@style/Toolbar</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Main activity theme. -->
|
|
||||||
<style name="ForecastTheme" parent="AppTheme">
|
|
||||||
<item name="actionBarStyle">@style/ActionBar.Solid.Sunshine.NoTitle</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!-- Settings activity theme. -->
|
<!-- Settings activity theme. -->
|
||||||
<style name="SettingsTheme" parent="AppTheme">
|
<style name="SettingsTheme" parent="AppTheme">
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- main activity action bar styles -->
|
<!-- main activity toolbar style -->
|
||||||
<style name="ActionBar.Solid.Sunshine.NoTitle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
|
<style name="Toolbar" parent="Widget.AppCompat.Toolbar">
|
||||||
<item name="displayOptions">useLogo|showHome</item>
|
<item name="android:background">?attr/colorPrimary</item>
|
||||||
<item name="logo">@drawable/ic_logo</item>
|
<item name="popupTheme">@style/Theme.AppCompat.Light</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Style for forecast listview -->
|
<!-- Style for forecast listview -->
|
||||||
|
|||||||
Reference in New Issue
Block a user