标题栏透明
2018-07-05 本文已影响18人
Il_mondo
final View view = findViewById(R.id.fixation_title_bar); // 需要透明的view
final View totalTitle = findViewById(R.id.total_title);
CompatNestedScrollView scrollView = findViewById(R.id.scrollView);
scrollView.setOnScrollChangedListener(new CompatNestedScrollView.OnScrollChangedListener() {
@Override
public void onScrollChanged(NestedScrollView scrollView, int x, int y, int oldx, int oldy) {
float totalTitleHeight = totalTitle.getHeight(); // 目标高度
float alphaValue = y / totalTitleHeight;
view.setAlpha(alphaValue);
}
});