admin
2021-06-11 ae4dc86b64bd8ef85bc832106741fb98e8d516da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.tejia.lijin.app.util.view;
 
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
 
import com.wpc.library.widget.TitleBar.HeaderHandler;
import com.tejia.lijin.app.R;
 
public class TranslationHeader extends RelativeLayout implements HeaderHandler {
    LinearLayout fakeHeader;
    View background;
 
    public TranslationHeader(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater inflater = LayoutInflater.from(context);
        inflater.inflate(R.layout.recommend_header, this, true);
        fakeHeader = findViewById(R.id.ll_first_page_search);
        background = findViewById(R.id.background);
        background.setAlpha(0);
    }
 
    @Override
    public void onChange(float ratio, float offsetY) {
        background.setAlpha(1 - ratio);
        fakeHeader.setTranslationY(fakeHeader.getTranslationY() - offsetY);
        background.setTranslationY(background.getTranslationY() - offsetY);
    }
}