小编Dcb*_*boy的帖子

像PInterest这样的布局

我想在我的代码中制作像pinterest的自定义视图,我在scrollview中使用scrollView和3 linearlayout我自定义我的视图名称waterfallView这里是代码:

public class WaterfallView extends LinearLayout {

private ListAdapter m_Adapter;
private OnClickListener onClickListener = null;
private LinearLayout m_Line1;
private LinearLayout m_Line2;
private LinearLayout m_Line3;

public WaterfallView(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
    InitLine();
}

public WaterfallView(Context context, AttributeSet attrs) {
    super(context, attrs);
    InitLine();
}

private void InitLine() {

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    lp.weight = 1;

    // line2
    m_Line1 = new LinearLayout(this.getContext());
    m_Line1.setOrientation(VERTICAL);
    m_Line1.setLayoutParams(lp);

    // line2
    m_Line2 = new LinearLayout(this.getContext());
    m_Line2.setOrientation(VERTICAL);
    m_Line2.setLayoutParams(lp);

    // …
Run Code Online (Sandbox Code Playgroud)

android

7
推荐指数
1
解决办法
3119
查看次数

标签 统计

android ×1