Skip to content

Commit 1ffe09c

Browse files
committed
完善筛选布局显示
1 parent 46f0272 commit 1ffe09c

File tree

10 files changed

+364
-13
lines changed

10 files changed

+364
-13
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
android:label="@string/app_name"
2020
android:supportsRtl="true"
2121
android:theme="@style/AppTheme">
22-
<activity android:name=".MainActivity">
22+
<activity android:name=".ui.MainActivity">
2323
<intent-filter>
2424
<action android:name="android.intent.action.MAIN"/>
2525
<category android:name="android.intent.category.LAUNCHER"/>
2626
</intent-filter>
2727
</activity>
28+
29+
<activity
30+
android:name=".ui.AboutActivity"
31+
android:screenOrientation="portrait"/>
2832
</application>
2933

3034
</manifest>

app/src/main/assets/about.html

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
6+
<style>
7+
h1,
8+
h2,
9+
h3,
10+
h4,
11+
h5,
12+
h6,
13+
p,
14+
blockquote {
15+
margin: 0;
16+
padding: 0;
17+
}
18+
body {
19+
font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", Arial, sans-serif;
20+
font-size: 13px;
21+
line-height: 18px;
22+
color: #737373;
23+
background-color: white;
24+
margin: 10px 13px 10px 13px;
25+
}
26+
table {
27+
margin: 10px 0 15px 0;
28+
border-collapse: collapse;
29+
}
30+
td,th {
31+
border: 1px solid #ddd;
32+
padding: 3px 10px;
33+
}
34+
th {
35+
padding: 5px 10px;
36+
}
37+
38+
a {
39+
color: #0069d6;
40+
}
41+
a:hover {
42+
color: #0050a3;
43+
text-decoration: none;
44+
}
45+
a img {
46+
border: none;
47+
}
48+
p {
49+
margin-bottom: 9px;
50+
}
51+
h1,
52+
h2,
53+
h3,
54+
h4,
55+
h5,
56+
h6 {
57+
color: #404040;
58+
line-height: 36px;
59+
}
60+
h1 {
61+
margin-bottom: 18px;
62+
font-size: 30px;
63+
}
64+
h2 {
65+
font-size: 24px;
66+
}
67+
h3 {
68+
font-size: 18px;
69+
}
70+
h4 {
71+
font-size: 16px;
72+
}
73+
h5 {
74+
font-size: 14px;
75+
}
76+
h6 {
77+
font-size: 13px;
78+
}
79+
hr {
80+
margin: 0 0 19px;
81+
border: 0;
82+
border-bottom: 1px solid #ccc;
83+
}
84+
blockquote {
85+
padding: 13px 13px 21px 15px;
86+
margin-bottom: 18px;
87+
font-family:georgia,serif;
88+
font-style: italic;
89+
}
90+
blockquote:before {
91+
content:"\201C";
92+
font-size:40px;
93+
margin-left:-10px;
94+
font-family:georgia,serif;
95+
color:#eee;
96+
}
97+
blockquote p {
98+
font-size: 14px;
99+
font-weight: 300;
100+
line-height: 18px;
101+
margin-bottom: 0;
102+
font-style: italic;
103+
}
104+
code, pre {
105+
font-family: Monaco, Andale Mono, Courier New, monospace;
106+
}
107+
code {
108+
background-color: #fee9cc;
109+
color: rgba(0, 0, 0, 0.75);
110+
padding: 1px 3px;
111+
font-size: 12px;
112+
-webkit-border-radius: 3px;
113+
-moz-border-radius: 3px;
114+
border-radius: 3px;
115+
}
116+
pre {
117+
display: block;
118+
padding: 14px;
119+
margin: 0 0 18px;
120+
line-height: 16px;
121+
font-size: 11px;
122+
border: 1px solid #d9d9d9;
123+
white-space: pre-wrap;
124+
word-wrap: break-word;
125+
}
126+
pre code {
127+
background-color: #fff;
128+
color:#737373;
129+
font-size: 11px;
130+
padding: 0;
131+
}
132+
sup {
133+
font-size: 0.83em;
134+
vertical-align: super;
135+
line-height: 0;
136+
}
137+
* {
138+
-webkit-print-color-adjust: exact;
139+
}
140+
@media screen and (min-width: 914px) {
141+
body {
142+
width: 854px;
143+
margin:10px auto;
144+
}
145+
}
146+
@media print {
147+
body,code,pre code,h1,h2,h3,h4,h5,h6 {
148+
color: black;
149+
}
150+
table, pre {
151+
page-break-inside: avoid;
152+
}
153+
}
154+
</style>
155+
<title>关注我吧</title>
156+
157+
</head>
158+
<body>
159+
<h4>关注我吧</h4>
160+
161+
<p><a href="https://github.com/sfsheng0322/StickyHeaderListView">项目开源地址:https://github.com/sfsheng0322/StickyHeaderListView</a></p>
162+
163+
<p><a href="https://github.com/sfsheng0322">GitHub主页</a></p>
164+
165+
<p><a href="http://www.jianshu.com/users/88509e7e2ed1/latest_articles">简书主页</a></p>
166+
167+
<p><a href="http://sunfusheng.com/">个人博客</a></p>
168+
169+
<p><a href="http://weibo.com/u/3852192525">新浪微博</a></p>
170+
</body>
171+
</html>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package com.sunfusheng.StickyHeaderListView.ui;
2+
3+
import android.os.Build;
4+
import android.os.Bundle;
5+
import android.support.v7.app.ActionBar;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.support.v7.widget.Toolbar;
8+
import android.view.KeyEvent;
9+
import android.view.Menu;
10+
import android.view.MenuItem;
11+
import android.webkit.WebSettings;
12+
import android.webkit.WebView;
13+
import android.webkit.WebViewClient;
14+
15+
import com.sunfusheng.StickyHeaderListView.R;
16+
17+
import butterknife.Bind;
18+
import butterknife.ButterKnife;
19+
20+
/**
21+
* Created by sunfusheng on 16/4/24.
22+
*/
23+
public class AboutActivity extends AppCompatActivity {
24+
25+
@Bind(R.id.toolbar)
26+
Toolbar toolbar;
27+
@Bind(R.id.webView)
28+
WebView webView;
29+
30+
@Override
31+
protected void onCreate(Bundle savedInstanceState) {
32+
super.onCreate(savedInstanceState);
33+
setContentView(R.layout.activity_about);
34+
ButterKnife.bind(this);
35+
36+
initView();
37+
}
38+
39+
private void initView() {
40+
initToolBar(toolbar, true, "关于");
41+
42+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
43+
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
44+
} else {
45+
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
46+
}
47+
48+
webView.loadUrl("file:///android_asset/about.html");
49+
webView.setWebViewClient(new WebViewClient() {
50+
@Override
51+
public boolean shouldOverrideUrlLoading(WebView view, String url) {
52+
view.loadUrl(url);
53+
return true;
54+
}
55+
});
56+
}
57+
58+
public void initToolBar(Toolbar toolbar, boolean homeAsUpEnabled, String title) {
59+
toolbar.setTitle(title);
60+
setSupportActionBar(toolbar);
61+
ActionBar actionBar = getSupportActionBar();
62+
if (actionBar != null) {
63+
actionBar.setDisplayHomeAsUpEnabled(homeAsUpEnabled);
64+
}
65+
}
66+
67+
@Override
68+
public boolean onCreateOptionsMenu(Menu menu) {
69+
return super.onCreateOptionsMenu(menu);
70+
}
71+
72+
@Override
73+
public boolean onOptionsItemSelected(MenuItem item) {
74+
switch (item.getItemId()) {
75+
case android.R.id.home:
76+
finish();
77+
return true;
78+
default:
79+
return super.onOptionsItemSelected(item);
80+
}
81+
}
82+
83+
@Override
84+
public boolean onKeyDown(int keyCode, KeyEvent event) {
85+
if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) {
86+
webView.goBack();//返回上一页面
87+
return true;
88+
}
89+
return super.onKeyDown(keyCode, event);
90+
}
91+
92+
}

app/src/main/java/com/sunfusheng/StickyHeaderListView/MainActivity.java renamed to app/src/main/java/com/sunfusheng/StickyHeaderListView/ui/MainActivity.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
package com.sunfusheng.StickyHeaderListView;
1+
package com.sunfusheng.StickyHeaderListView.ui;
22

33
import android.app.Activity;
44
import android.content.Context;
5+
import android.content.Intent;
56
import android.os.Bundle;
67
import android.os.Handler;
78
import android.os.Message;
89
import android.support.v7.app.AppCompatActivity;
910
import android.view.View;
1011
import android.widget.AbsListView;
12+
import android.widget.FrameLayout;
1113
import android.widget.ListView;
1214
import android.widget.RelativeLayout;
1315
import android.widget.TextView;
1416

17+
import com.sunfusheng.StickyHeaderListView.R;
1518
import com.sunfusheng.StickyHeaderListView.adapter.TravelingAdapter;
1619
import com.sunfusheng.StickyHeaderListView.model.ChannelEntity;
1720
import com.sunfusheng.StickyHeaderListView.model.FilterData;
@@ -43,6 +46,12 @@ public class MainActivity extends AppCompatActivity {
4346
RelativeLayout rlBar;
4447
@Bind(R.id.tv_title)
4548
TextView tvTitle;
49+
@Bind(R.id.view_title_bg)
50+
View viewTitleBg;
51+
@Bind(R.id.view_action_more_bg)
52+
View viewActionMoreBg;
53+
@Bind(R.id.fl_action_more)
54+
FrameLayout flActionMore;
4655

4756
private Context mContext;
4857
private Activity mActivity;
@@ -68,7 +77,6 @@ public class MainActivity extends AppCompatActivity {
6877
private int adViewTopSpace; // 广告视图距离顶部的距离
6978

7079
private int filterViewPosition = 4; // 筛选视图的位置
71-
private int filterViewHeight = 46; // 筛选视图的高度
7280
private int filterViewTopSpace; // 筛选视图距离顶部的距离
7381

7482
private Handler mHandler = new Handler() {
@@ -78,7 +86,6 @@ public void handleMessage(Message msg) {
7886
}
7987
};
8088

81-
8289
@Override
8390
protected void onCreate(Bundle savedInstanceState) {
8491
super.onCreate(savedInstanceState);
@@ -163,7 +170,6 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
163170
View filterView = listView.getChildAt(filterViewPosition - firstVisibleItem);
164171
if (filterView != null) {
165172
filterViewTopSpace = DensityUtil.px2dip(mContext, filterView.getTop());
166-
filterViewHeight = DensityUtil.px2dip(mContext, filterView.getHeight());
167173
}
168174

169175
// 处理筛选是否吸附在顶部
@@ -206,6 +212,13 @@ public void onFilterClick(int position) {
206212
}
207213
}
208214
});
215+
216+
flActionMore.setOnClickListener(new View.OnClickListener() {
217+
@Override
218+
public void onClick(View v) {
219+
startActivity(new Intent(mActivity, AboutActivity.class));
220+
}
221+
});
209222
}
210223

211224
// 处理标题栏颜色渐变
@@ -215,8 +228,9 @@ private void handleTitleBarColorEvaluate() {
215228
if (fraction > 1.0f) {
216229
fraction = 1.0f;
217230
}
231+
viewTitleBg.setAlpha(1.0f - fraction);
232+
viewActionMoreBg.setAlpha(1.0f - fraction);
218233
rlBar.setBackgroundColor(ColorUtil.getNewColorByStartEndColor(mContext, fraction, R.color.transparent, R.color.orange));
219-
tvTitle.setTextColor(ColorUtil.getNewColorByStartEndColor(mContext, fraction, R.color.orange, R.color.white));
220234
}
221235

222236
@Override
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<solid android:color="@color/half_transparent" />
5+
<corners android:radius="15dp"/>
6+
7+
</shape>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:fitsSystemWindows="true"
7+
android:orientation="vertical"
8+
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
9+
10+
<include layout="@layout/app_toolbar"/>
11+
12+
<WebView
13+
android:id="@+id/webView"
14+
android:layout_width="match_parent"
15+
android:layout_height="match_parent"/>
16+
17+
</LinearLayout>

0 commit comments

Comments
 (0)