Skip to content

Commit ee4e568

Browse files
committed
UserActivity: 透明appbar
1 parent 8aca9f5 commit ee4e568

File tree

8 files changed

+59
-41
lines changed

8 files changed

+59
-41
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
<activity
6767
android:name=".ui.activity.BlocksActivity"
6868
android:label="@string/title_activity_blocks"
69-
android:theme="@style/AppTheme.NoActionBar.Transparent"/>
69+
android:theme="@style/AppTheme.NoActionBar.TransparentBackground"/>
7070
<activity
7171
android:name=".ui.activity.UserActivity"
7272
android:label="@string/title_activity_user"
73-
android:theme="@style/AppTheme"/>
73+
android:theme="@style/AppTheme.NoActionBar.TransparentStatusBar"/>
7474
<activity
7575
android:name=".ui.activity.ReplyActivity"
7676
android:label="@string/title_activity_reply"

app/src/main/kotlin/com/rayfantasy/icode/ui/activity/UserActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import org.jetbrains.anko.alert
1818
import org.jetbrains.anko.startActivity
1919
import java.util.*
2020

21-
class UserActivity : ActivityBindingStatus() {
21+
class UserActivity : ActivityBase() {
2222
private lateinit var adapter: UserListAdapter
2323
private var isRefreshing: Boolean = false
2424
private lateinit var request: Request<out Any>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2016 Alex Zhang aka. ztc1997
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+
18+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
19+
<gradient android:angle="90"
20+
android:startColor="@color/appbar_overlay_bottom"
21+
android:endColor="@color/appbar_overlay_top"/>
22+
</shape>

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,22 @@
99
name="theme"
1010
type="com.rayfantasy.icode.model.ICodeTheme"/>
1111
</data>
12-
<android.support.design.widget.CoordinatorLayout
12+
<FrameLayout
1313
android:layout_width="match_parent"
1414
android:layout_height="match_parent"
15-
android:fitsSystemWindows="true"
16-
app:statusBarBackgroundColor="@{theme.colorPrimaryDark}"
1715
tools:context=".ui.activity.UserActivity">
1816

19-
<android.support.design.widget.AppBarLayout
17+
<include layout="@layout/content_user"/>
18+
19+
<android.support.v7.widget.Toolbar
20+
android:id="@+id/toolbar"
2021
android:layout_width="match_parent"
2122
android:layout_height="wrap_content"
22-
android:theme="@style/AppTheme.AppBarOverlay">
23-
24-
<android.support.v7.widget.Toolbar
25-
android:id="@+id/toolbar"
26-
android:layout_width="match_parent"
27-
android:layout_height="?attr/actionBarSize"
28-
android:background="@{theme.colorPrimary}"
29-
app:popupTheme="@style/AppTheme.PopupOverlay"/>
30-
31-
</android.support.design.widget.AppBarLayout>
32-
33-
<include layout="@layout/content_user"/>
23+
android:minHeight="?attr/actionBarSize"
24+
android:background="@drawable/appbar_overlay"
25+
android:fitsSystemWindows="true"
26+
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
27+
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
3428

3529
<!--<android.support.design.widget.FloatingActionButton-->
3630
<!--android:id="@+id/fab"-->
@@ -41,5 +35,5 @@
4135
<!--android:src="@android:drawable/ic_dialog_email"-->
4236
<!--app:backgroundTintList="@{theme.colorAccent}"/>-->
4337

44-
</android.support.design.widget.CoordinatorLayout>
38+
</FrameLayout>
4539
</layout>
Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:layout_width="match_parent"
4-
android:layout_height="match_parent">
2+
<android.support.v4.widget.SwipeRefreshLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:id="@+id/user_swipe">
57

6-
<android.support.v4.widget.SwipeRefreshLayout
8+
<android.support.v7.widget.RecyclerView
79
android:layout_width="match_parent"
10+
android:id="@+id/user_recyclerview"
811
android:layout_height="match_parent"
9-
android:id="@+id/user_swipe"
12+
android:layout_alignParentTop="true"
1013
android:layout_alignParentLeft="true"
11-
android:layout_alignParentStart="true"
12-
android:layout_marginTop="55dp">
14+
android:layout_alignParentStart="true">
1315

14-
15-
<android.support.v7.widget.RecyclerView
16-
android:layout_width="match_parent"
17-
android:id="@+id/user_recyclerview"
18-
android:layout_height="match_parent"
19-
android:layout_alignParentTop="true"
20-
android:layout_alignParentLeft="true"
21-
android:layout_alignParentStart="true"
22-
android:layout_marginTop="60dp">
23-
24-
</android.support.v7.widget.RecyclerView>
25-
</android.support.v4.widget.SwipeRefreshLayout>
26-
</RelativeLayout>
16+
</android.support.v7.widget.RecyclerView>
17+
</android.support.v4.widget.SwipeRefreshLayout>

app/src/main/res/values-v21/styles.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
<item name="android:statusBarColor">@android:color/transparent</item>
88
<item name="android:windowContentTransitions">true</item>
99
</style>
10+
11+
<style name="AppTheme.NoActionBar.TransparentStatusBar">
12+
<item name="android:statusBarColor">@color/appbar_overlay_top</item>
13+
<item name="android:windowTranslucentStatus">true</item>
14+
</style>
1015
</resources>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<color name="light_color">#ffffff</color>
1414
<color name="light_color2">#ff87cefa</color>
1515

16+
<color name="appbar_overlay_top">#99000000</color>
17+
<color name="appbar_overlay_bottom">#00000000</color>
18+
1619
<!--主题:蓝-->
1720
<color name="colorPrimary_blue">#03a9f4</color>
1821
<color name="colorPrimaryDark_blue">#0288d1</color>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
<item name="windowNoTitle">true</item>
1717
</style>
1818

19-
<style name="AppTheme.NoActionBar.Transparent">
19+
<style name="AppTheme.NoActionBar.TransparentStatusBar">
20+
</style>
21+
22+
<style name="AppTheme.NoActionBar.TransparentBackground">
2023
<item name="android:windowBackground">@android:color/transparent</item>
2124
<item name="android:windowIsTranslucent">true</item>
2225
</style>

0 commit comments

Comments
 (0)