Skip to content

Commit 26159a5

Browse files
committed
Updated our landscape layout to be close to where we want it.
1 parent 20231d8 commit 26159a5

10 files changed

Lines changed: 164 additions & 73 deletions

File tree

app/src/main/java/com/example/android/sunshine/app/DetailFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
108108
mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
109109
}
110110

111-
View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
111+
View rootView = inflater.inflate(R.layout.fragment_detail_start, container, false);
112112
mIconView = (ImageView) rootView.findViewById(R.id.detail_icon);
113113
mDateView = (TextView) rootView.findViewById(R.id.detail_date_textview);
114114
mDescriptionView = (TextView) rootView.findViewById(R.id.detail_forecast_textview);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!-- Detail Layout for Grid -->
2+
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:id="@+id/detail_additional_pane"
6+
android:layout_width="match_parent"
7+
android:layout_height="0dp"
8+
android:layout_weight="2"
9+
android:background="@color/detail_accent_pane_background"
10+
android:paddingBottom="@dimen/abc_list_item_padding_horizontal_material"
11+
android:paddingEnd="@dimen/forecast_detail_horizontal_padding"
12+
android:paddingLeft="@dimen/forecast_detail_horizontal_padding"
13+
android:paddingRight="@dimen/forecast_detail_horizontal_padding"
14+
android:paddingStart="@dimen/forecast_detail_horizontal_padding"
15+
android:paddingTop="@dimen/abc_list_item_padding_horizontal_material"
16+
app:columnCount="2">
17+
18+
<TextView
19+
android:id="@+id/detail_humidity_label_textview"
20+
android:layout_height="wrap_content"
21+
android:fontFamily="sans-serif"
22+
android:gravity="center_vertical"
23+
android:text="@string/humidity"
24+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
25+
android:textColor="@color/detail_accent_label"
26+
app:layout_columnWeight="1"
27+
app:layout_gravity="fill"
28+
app:layout_rowWeight="1" />
29+
30+
<TextView
31+
android:id="@+id/detail_humidity_textview"
32+
android:gravity="center_vertical"
33+
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
34+
android:textColor="@android:color/white"
35+
app:layout_gravity="fill"
36+
tools:text="38%" />
37+
38+
<TextView
39+
android:id="@+id/detail_pressure_label_textview"
40+
android:fontFamily="sans-serif"
41+
android:gravity="center_vertical"
42+
android:text="@string/pressure"
43+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
44+
android:textColor="@color/detail_accent_label"
45+
app:layout_gravity="fill"
46+
app:layout_rowWeight="1" />
47+
48+
<TextView
49+
android:id="@+id/detail_pressure_textview"
50+
android:gravity="center_vertical"
51+
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
52+
android:textColor="@android:color/white"
53+
app:layout_gravity="fill"
54+
tools:text="995 hPa" />
55+
56+
<TextView
57+
android:id="@+id/detail_wind_label_textview"
58+
android:fontFamily="sans-serif"
59+
android:gravity="center_vertical"
60+
android:text="@string/wind"
61+
android:textColor="@color/detail_accent_label"
62+
android:textSize="20sp"
63+
app:layout_gravity="fill"
64+
app:layout_rowWeight="1" />
65+
66+
67+
<TextView
68+
android:id="@+id/detail_wind_textview"
69+
android:gravity="center_vertical"
70+
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
71+
android:textColor="@android:color/white"
72+
app:layout_gravity="fill"
73+
tools:text="4km/h NW" />
74+
</android.support.v7.widget.GridLayout>
75+

app/src/main/res/layout/fragment_detail.xml

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
<!-- Master layout. -->
1717
<LinearLayout
1818
xmlns:android="http://schemas.android.com/apk/res/android"
19-
xmlns:tools="http://schemas.android.com/tools"
20-
xmlns:app="http://schemas.android.com/apk/res-auto"
2119
android:layout_width="match_parent"
2220
android:layout_height="match_parent"
2321
android:orientation="vertical">
@@ -33,76 +31,10 @@
3331
android:layout_height="0dp"
3432
android:layout_weight="3"/>
3533

36-
<android.support.v7.widget.GridLayout
37-
android:id="@+id/detail_additional_pane"
34+
<include layout="@layout/detail_extras_grid"
3835
android:layout_width="match_parent"
3936
android:layout_height="0dp"
40-
android:layout_weight="2"
41-
app:columnCount="2"
42-
android:background="@color/detail_accent_pane_background"
43-
android:paddingBottom="@dimen/abc_list_item_padding_horizontal_material"
44-
android:paddingTop="@dimen/abc_list_item_padding_horizontal_material"
45-
android:paddingLeft="@dimen/forecast_detail_horizontal_padding"
46-
android:paddingStart="@dimen/forecast_detail_horizontal_padding"
47-
android:paddingRight="@dimen/forecast_detail_horizontal_padding"
48-
android:paddingEnd="@dimen/forecast_detail_horizontal_padding">
37+
android:layout_weight="2"/>
4938

50-
<TextView
51-
android:id="@+id/detail_humidity_label_textview"
52-
android:layout_height="wrap_content"
53-
android:fontFamily="sans-serif"
54-
android:gravity="center_vertical"
55-
android:text="@string/humidity"
56-
android:textAppearance="@style/TextAppearance.AppCompat.Title"
57-
android:textColor="@color/detail_accent_label"
58-
app:layout_columnWeight="1"
59-
app:layout_gravity="fill"
60-
app:layout_rowWeight="1" />
61-
62-
<TextView
63-
android:id="@+id/detail_humidity_textview"
64-
android:gravity="center_vertical"
65-
tools:text="38%"
66-
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
67-
android:textColor="@android:color/white"
68-
app:layout_gravity="fill"/>
69-
70-
<TextView
71-
android:id="@+id/detail_pressure_label_textview"
72-
android:fontFamily="sans-serif"
73-
android:gravity="center_vertical"
74-
android:text="@string/pressure"
75-
android:textAppearance="@style/TextAppearance.AppCompat.Title"
76-
android:textColor="@color/detail_accent_label"
77-
app:layout_gravity="fill"
78-
app:layout_rowWeight="1"/>
79-
80-
<TextView
81-
android:id="@+id/detail_pressure_textview"
82-
android:gravity="center_vertical"
83-
tools:text="995 hPa"
84-
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
85-
android:textColor="@android:color/white"
86-
app:layout_gravity="fill"/>
87-
88-
<TextView
89-
android:id="@+id/detail_wind_label_textview"
90-
android:fontFamily="sans-serif"
91-
android:gravity="center_vertical"
92-
android:text="@string/wind"
93-
android:textColor="@color/detail_accent_label"
94-
android:textSize="20sp"
95-
app:layout_gravity="fill"
96-
app:layout_rowWeight="1" />
97-
98-
99-
<TextView
100-
android:id="@+id/detail_wind_textview"
101-
android:gravity="center_vertical"
102-
tools:text="4km/h NW"
103-
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
104-
android:textColor="@android:color/white"
105-
app:layout_gravity="fill" />
106-
</android.support.v7.widget.GridLayout>
10739

10840
</LinearLayout>

app/src/main/res/layout/list_item_forecast.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
android:layout_width="match_parent"
2121
android:layout_height="wrap_content"
2222
android:background="@drawable/touch_selector"
23+
android:paddingLeft="@dimen/list_item_extra_padding"
24+
android:paddingRight="@dimen/list_item_extra_padding"
2325
>
2426

2527
<LinearLayout

app/src/main/res/values-land/refs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
2020
-->
2121
<!-- Replace fragment detail view with layout that takes advantage of more available width.-->
22-
<item type="layout" name="fragment_detail">@layout/fragment_detail_wide</item>
22+
<item type="layout" name="fragment_detail_start">@layout/fragment_detail_wide</item>
2323
</resources>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (C) 2015 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<resources>
18+
<item type="layout" name="fragment_detail_start">@layout/fragment_detail</item>
19+
</resources>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
Copyright (C) 2015 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<resources>
17+
<!-- Extra List Item Margin (tablet-only) -->
18+
<dimen name="list_item_extra_padding">80dp</dimen>
19+
<dimen name="forecast_temperature_space">@dimen/abc_list_item_padding_horizontal_material</dimen>
20+
<dimen name="detail_view_padding_vertical">@dimen/abc_list_item_padding_horizontal_material</dimen>
21+
22+
</resources>

app/src/main/res/values-sw600dp/refs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
-->
2121

2222
<!-- Replace fragment detail view with layout that takes advantage of more available width.-->
23-
<item type="layout" name="fragment_detail">@layout/fragment_detail_wide</item>
23+
<item type="layout" name="fragment_detail_start">@layout/fragment_detail_wide</item>
2424
</resources>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
Copyright (C) 2015 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<resources>
17+
<!-- Extra List Item Margin (tablet-only) -->
18+
<dimen name="list_item_extra_padding">80dp</dimen>
19+
<dimen name="detail_view_padding_vertical">@dimen/abc_list_item_padding_horizontal_material</dimen>
20+
<dimen name="forecast_temperature_space">@dimen/abc_list_item_padding_horizontal_material</dimen>
21+
22+
</resources>

app/src/main/res/values/refs.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (C) 2015 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<resources>
18+
<item type="layout" name="fragment_detail_start">@layout/fragment_detail</item>
19+
</resources>

0 commit comments

Comments
 (0)