我需要 android 中自定义手风琴视图的参考

I need a reference for custom accordion view in android

我正在做一个需要在 android 中自定义手风琴视图的项目。如果有人处理过此类要求,请告诉我。提前致谢。

请试试这个link这可能有帮助 https://github.com/hamsterready/android-accordion-view

这是我的代码

public class AccordianView extends LinearLayout implements View.OnClickListener {
    private final TextView headerText;
    private final LinearLayout llChildAcoradian;
    private final Context context;
    private boolean isOpen = false;
    private static final int ANIM_DURATION_FOR_ACCORDIAN = 500;


    public AccordianView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        setClickable(true);
        setFocusable(true);
        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.AccordianView, 0, 0);
        String titleText = a.getString(R.styleable.AccordianView_accor_header_text);
        float textSize = a.getFloat(R.styleable.AccordianView_accor_header_text_size, 16.0f);
        a.recycle();

        setOrientation(LinearLayout.VERTICAL);
        setGravity(Gravity.CENTER_VERTICAL);

        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.layout_accordian, this, true);

        headerText = (TextView) getChildAt(0);
        headerText.setText(titleText);
        headerText.setTextSize(textSize);
        headerText.setOnClickListener(this);

        llChildAcoradian = (LinearLayout) getChildAt(1);

        headerText.setText("Now :" + (llChildAcoradian.getVisibility() == View
                .VISIBLE ? "Open" : "Closed"));
        llChildAcoradian.setVisibility(View.VISIBLE);


    }

    @Override
    public void onClick(View v) {

        ExpandAndCollapseAnimation expandAni = new ExpandAndCollapseAnimation(llChildAcoradian, ANIM_DURATION_FOR_ACCORDIAN);
        llChildAcoradian.startAnimation(expandAni);
    }


    public void toggleViewState()
    {
        headerText.performClick();
    }



}