Skip to content

Commit 01cbc9f

Browse files
committed
Updated the layout and dimensions to get us ready for lots of real estate.
1 parent 45627b2 commit 01cbc9f

2 files changed

Lines changed: 81 additions & 38 deletions

File tree

app/src/main/res/layout-sw600dp/activity_main.xml

Lines changed: 76 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,88 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
-->
16-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
16+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
17+
xmlns:app="http://schemas.android.com/apk/res-auto"
1718
xmlns:tools="http://schemas.android.com/tools"
1819
android:layout_width="match_parent"
19-
android:layout_height="match_parent"
20-
android:orientation="vertical">
21-
22-
<android.support.v7.widget.Toolbar
23-
android:id="@+id/toolbar"
24-
android:layout_width="match_parent"
25-
android:layout_height="?attr/actionBarSize"
26-
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
27-
>
28-
<ImageView
29-
android:layout_width="wrap_content"
30-
android:layout_height="match_parent"
31-
android:src="@drawable/ic_logo"
32-
android:scaleType="center"/>
33-
</android.support.v7.widget.Toolbar>
20+
android:layout_height="match_parent">
3421

3522
<LinearLayout
23+
android:id="@+id/appbar"
3624
android:layout_width="match_parent"
37-
android:layout_height="match_parent"
38-
android:baselineAligned="false"
39-
android:divider="?android:attr/dividerHorizontal"
40-
android:orientation="horizontal"
41-
tools:context="com.example.android.sunshine.app.MainActivity">
42-
43-
<!--
44-
This layout is a two-pane layout for the Items master/detail flow.
45-
-->
46-
47-
<fragment
48-
android:id="@+id/fragment_forecast"
49-
android:name="com.example.android.sunshine.app.ForecastFragment"
50-
android:layout_width="0dp"
51-
android:layout_height="match_parent"
52-
android:layout_weight="2"
53-
tools:layout="@android:layout/list_content" />
25+
android:layout_height="wrap_content"
26+
android:layout_alignParentTop="true"
27+
android:background="?attr/colorPrimary"
28+
android:elevation="@dimen/appbar_elevation"
29+
android:orientation="vertical">
5430

31+
<android.support.v7.widget.Toolbar
32+
android:id="@+id/toolbar"
33+
android:layout_width="match_parent"
34+
android:layout_height="?attr/actionBarSize"
35+
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
36+
37+
<!-- These FrameLayouts are only there to line the image up with the keyline correctly, since
38+
we cannot do addition of dimensions/attributes otherwise -->
5539
<FrameLayout
56-
android:id="@+id/weather_detail_container"
57-
android:layout_width="0dp"
58-
android:layout_height="match_parent"
59-
android:layout_weight="4" />
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:layout_marginLeft="@dimen/abc_list_item_padding_horizontal_material"
43+
android:layout_marginStart="@dimen/abc_list_item_padding_horizontal_material"
44+
>
45+
<FrameLayout
46+
android:layout_width="wrap_content"
47+
android:layout_height="wrap_content"
48+
android:layout_marginLeft="@dimen/list_icon"
49+
android:layout_marginStart="@dimen/list_icon"
50+
android:paddingLeft="@dimen/abc_list_item_padding_horizontal_material"
51+
android:paddingStart="@dimen/abc_list_item_padding_horizontal_material">
6052

53+
<ImageView
54+
android:layout_width="wrap_content"
55+
android:layout_height="?attr/listPreferredItemHeight"
56+
android:layout_gravity="center_vertical"
57+
android:src="@drawable/ic_logo"
58+
android:contentDescription="@string/app_name"/>
59+
</FrameLayout>
60+
</FrameLayout>
6161
</LinearLayout>
62-
</LinearLayout>
62+
63+
<!-- This is used as a strut to create two columns in our RelativeLayout -->
64+
<android.support.v4.widget.Space
65+
android:id="@+id/layout_center"
66+
android:layout_width="0dp"
67+
android:layout_height="0dp"
68+
android:layout_centerInParent="true" />
69+
70+
<fragment
71+
android:id="@+id/fragment_forecast"
72+
android:name="com.example.android.sunshine.app.ForecastFragment"
73+
android:layout_width="0dp"
74+
android:layout_height="match_parent"
75+
android:layout_alignEnd="@id/layout_center"
76+
android:layout_alignParentLeft="true"
77+
android:layout_alignParentStart="true"
78+
android:layout_alignRight="@id/layout_center"
79+
android:layout_below="@id/appbar"
80+
tools:layout="@android:layout/list_content" />
81+
82+
<!-- We set elevation here only so the detail view doesn't get occluded
83+
by the AppBar -->
84+
85+
<FrameLayout
86+
android:id="@+id/weather_detail_container"
87+
android:layout_width="match_parent"
88+
android:layout_height="match_parent"
89+
android:layout_alignLeft="@id/layout_center"
90+
android:layout_alignParentEnd="true"
91+
android:layout_alignParentRight="true"
92+
android:layout_marginTop="?attr/actionBarSize"
93+
android:layout_alignStart="@id/layout_center"
94+
android:elevation="@dimen/appbar_elevation"
95+
android:paddingRight="@dimen/abc_list_item_padding_horizontal_material"
96+
android:paddingEnd="@dimen/abc_list_item_padding_horizontal_material"
97+
android:paddingBottom="@dimen/abc_list_item_padding_horizontal_material"
98+
/>
99+
100+
</RelativeLayout>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@
3838
<!-- Extra Padding -->
3939
<dimen name="detail_view_extra_padding">@dimen/abc_list_item_padding_horizontal_material</dimen>
4040

41+
<!-- Needed if we aren't including the Material Design Library -->
42+
<dimen name="appbar_elevation">4dp</dimen>
43+
44+
<!-- The amount we want the details view to overlap the app bar -->
45+
<dimen name="details_app_bar_overlap">24dp</dimen>
4146
</resources>

0 commit comments

Comments
 (0)