This commit is contained in:
ScorpioMiku
2018-09-10 22:12:23 +08:00
parent efac56b197
commit f808c5dea6
6 changed files with 225 additions and 136 deletions

View File

@@ -23,16 +23,7 @@ import butterknife.BindView;
public class RecipeActivity extends BaseActivity {
@BindView(R.id.recipe_list)
RecyclerView recipeList;
@BindView(R.id.nested_scorll_view)
NestedScrollView nestedScorllView;
@BindView(R.id.tv_title)
TextView tvTitle;
@BindView(R.id.tv_subTitle)
TextView tvSubTitle;
@BindView(R.id.ll_title)
LinearLayout llTitle;
private RecommendFood recommendFood;
private Menu menu;
@@ -52,20 +43,6 @@ public class RecipeActivity extends BaseActivity {
public void initViews(Bundle savedInstanceState) {
final int changedHeight = UiUtils.dp2px(this, 214);
nestedScorllView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
float scale = (float) v.getScrollY() / changedHeight;
//变化范围0-255 表示从透明到纯色背景
float alpha = scale * 255 >= 255 ? 255 : scale * 255;
llTitle.setBackgroundColor(Color.argb((int) alpha, 212, 62, 55));
tvTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
tvSubTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
}
});
Intent intent = getIntent();
recommendFood = (RecommendFood) intent.getSerializableExtra("SEND_OBJECT");
@@ -93,7 +70,5 @@ public class RecipeActivity extends BaseActivity {
public void initRecyclerView() {
super.initRecyclerView();
MenuAdapter adapter = new MenuAdapter(menuList, this);
recipeList.setAdapter(adapter);
recipeList.setLayoutManager(new LinearLayoutManager(this));
}
}