Example usage for android.widget LinearLayout LinearLayout

List of usage examples for android.widget LinearLayout LinearLayout

Introduction

In this page you can find the example usage for android.widget LinearLayout LinearLayout.

Prototype

public LinearLayout(Context context) 

Source Link

Usage

From source file:com.chuger.bithdayapp.view.auth.AuthDialog.java

private void setUpWebView(final int margin) {
    final LinearLayout webViewContainer = new LinearLayout(getContext());
    mWebView = new WebView(getContext());
    mWebView.setVerticalScrollBarEnabled(false);
    mWebView.setHorizontalScrollBarEnabled(false);
    mWebView.setWebViewClient(new AuthDialog.FbWebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl(mUrl);/*from   www  . jav a  2  s  . c  o m*/
    mWebView.setLayoutParams(FILL);
    mWebView.setVisibility(View.INVISIBLE);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(mWebView);
    mContent.addView(webViewContainer);
}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    Resources res = getResources();
    boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortrait) {
        mColumnWidth = (int) (res.getDisplayMetrics().widthPixels * 0.87);
    } else {/* w w  w  .j a v  a 2s  .  com*/
        mColumnWidth = (int) (res.getDisplayMetrics().density * 320);
    }

    mGestureDetector = new GestureDetector(getContext(), new GestureListener());
    mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f));
    mAutoScroller = new AutoScroller(getContext(), this);
    mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN
            : AutoScroller.AutoScrollMode.POSITION);
    mDragItem = new DragItem(getContext());

    mRootLayout = new FrameLayout(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    mColumnLayout = new LinearLayout(getContext());
    mColumnLayout.setOrientation(LinearLayout.HORIZONTAL);
    mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mColumnLayout.setMotionEventSplittingEnabled(false);

    mRootLayout.addView(mColumnLayout);
    mRootLayout.addView(mDragItem.getDragItemView());
    addView(mRootLayout);
}

From source file:com.google.android.gcm.demo.ui.GroupsFragment.java

@Override
public void refresh() {
    float density = getActivity().getResources().getDisplayMetrics().density;
    SimpleArrayMap<String, Sender> senders = mSenders.getSenders();
    LinearLayout sendersList = new LinearLayout(getActivity());
    sendersList.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < senders.size(); i++) {
        Sender sender = senders.valueAt(i);
        if (sender.groups.size() > 0) {
            LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
                    .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
            ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
            TextView senderText = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
            senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
            senderIcon.setImageResource(R.drawable.cloud_googblue);
            senderIcon.setPadding(0, 0, (int) (8 * density), 0);
            senderText.setText(getString(R.string.groups_sender_id, sender.senderId));
            sendersList.addView(senderRow);
            for (DeviceGroup deviceGroup : sender.groups.values()) {
                LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
                        .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
                ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
                TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
                Button button = (Button) row.findViewById(R.id.widget_itbr_button);
                icon.setImageResource(R.drawable.group_grey600);
                label.setText(deviceGroup.notificationKeyName);
                label.setBackgroundResource(selectableBackgroundResource);
                label.setTag(R.id.tag_action, ACTION_OPEN_GROUP);
                label.setTag(R.id.tag_senderid, sender.senderId);
                label.setTag(R.id.tag_group, deviceGroup.notificationKeyName);
                label.setOnClickListener(this);

                button.setText(R.string.groups_delete);
                button.setTag(R.id.tag_action, ACTION_DELETE_GROUP);
                button.setTag(R.id.tag_senderid, sender.senderId);
                button.setTag(R.id.tag_group, deviceGroup.notificationKeyName);
                button.setOnClickListener(this);
                row.setPadding((int) (16 * density), 0, 0, 0);
                sendersList.addView(row);
            }//w ww  .j  a  v a  2 s  . c o  m
        }
    }
    if (sendersList.getChildCount() == 0) {
        TextView noTokens = new TextView(getActivity());
        noTokens.setText(getString(R.string.groups_no_groups_available));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.groups_list_wrapper);
    topicsView.removeAllViews();
    topicsView.addView(sendersList);
}

From source file:base.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//w ww . j a  v a 2 s  .  c  o  m
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
    ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX);
    int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
    if (colorStateList != null) {
        tabTextColor = colorStateList;
    } else {
        tabTextColor = getColorStateList(textPrimaryColor);
    }

    underlineColor = textPrimaryColor;
    dividerColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;
    paddingLeft = a.getDimensionPixelSize(PADDING_LEFT_INDEX, paddingLeft);
    paddingRight = a.getDimensionPixelSize(PADDING_RIGHT_INDEX, paddingRight);
    a.recycle();

    //In case we have the padding they must be equal so we take the biggest
    if (paddingRight < paddingLeft) {
        paddingRight = paddingLeft;
    }

    if (paddingLeft < paddingRight) {
        paddingLeft = paddingRight;
    }
    // get custom attrs
    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);

    //tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId);

    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle);
    tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
    tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP);
    tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE);
    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.krayzk9s.imgurholo.ui.AlbumsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection
    Activity activity = getActivity();/*ww  w. j a v a2 s  .co m*/
    switch (item.getItemId()) {
    case R.id.action_refresh:
        urls = new ArrayList<String>();
        imageAdapter.notifyDataSetChanged();
        getImages();
        return true;
    case R.id.action_new:
        final EditText newTitle = new EditText(activity);
        newTitle.setSingleLine();
        newTitle.setHint(R.string.hint_album_title);
        final EditText newDescription = new EditText(activity);
        newDescription.setHint(R.string.body_hint_description);
        LinearLayout linearLayout = new LinearLayout(activity);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.addView(newTitle);
        linearLayout.addView(newDescription);
        new AlertDialog.Builder(activity).setTitle(R.string.dialog_new_album_title).setView(linearLayout)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        NewAlbumAsync messagingAsync = new NewAlbumAsync(newTitle.getText().toString(),
                                newDescription.getText().toString(),
                                ((ImgurHoloActivity) getActivity()).getApiCall(), null, null);
                        messagingAsync.execute();
                    }
                }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // Do nothing.
                    }
                }).show();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.nextgis.mobile.map.RemoteTMSLayer.java

protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName,
        String layerUrl, int type, final RemoteTMSLayer layer) {
    final LinearLayout linearLayout = new LinearLayout(map.getContext());
    final EditText input = new EditText(map.getContext());
    input.setText(layerName);//from w  ww . j  a  v a 2  s.  com

    final EditText url = new EditText(map.getContext());
    url.setText(layerUrl);

    final TextView stLayerName = new TextView(map.getContext());
    stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":");

    final TextView stLayerUrl = new TextView(map.getContext());
    stLayerUrl.setText(map.getContext().getString(R.string.layer_url) + ":");

    final TextView stLayerType = new TextView(map.getContext());
    stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":");

    final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(),
            android.R.layout.simple_spinner_item);
    final Spinner spinner = new Spinner(map.getContext());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    adapter.add(map.getContext().getString(R.string.tmstype_osm));
    adapter.add(map.getContext().getString(R.string.tmstype_normal));
    adapter.add(map.getContext().getString(R.string.tmstype_ngw));

    if (type == TMSTYPE_OSM) {
        spinner.setSelection(0);
    } else {
        spinner.setSelection(1);
    }

    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.addView(stLayerName);
    linearLayout.addView(input);
    linearLayout.addView(stLayerUrl);
    linearLayout.addView(url);
    linearLayout.addView(stLayerType);
    linearLayout.addView(spinner);

    new AlertDialog.Builder(map.getContext())
            .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties)
            //                                    .setMessage(message)
            .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    int tmsType = 0;
                    switch (spinner.getSelectedItemPosition()) {
                    case 0:
                    case 1:
                        tmsType = TMSTYPE_OSM;
                        break;
                    case 2:
                    case 3:
                        tmsType = TMSTYPE_NORMAL;
                        break;
                    }

                    if (bCreate) {
                        create(map, input.getText().toString(), url.getText().toString(), tmsType);
                    } else {
                        layer.setName(input.getText().toString());
                        layer.setTMSType(tmsType);
                        map.onLayerChanged(layer);
                    }
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Do nothing.
                    Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show();
                }
            }).show();
}

From source file:com.bslee.logtoolapk.widget.FragmentTabHost.java

@Deprecated
private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();//from   ww w.j  av  a  2s .co  m

    super.setOnTabChangedListener(this);

    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

private LinearLayout createContainerLayout(Context context) {
    LinearLayout container = new LinearLayout(context);
    container.setId(R.id.absQuizViewContainer);
    container.setOrientation(LinearLayout.VERTICAL);
    return container;
}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

/**
 * @param fragmentDetail        the fragment detail  to use.
 * @param attrs                 attributes.
 * @param requestCode           the code for starting the activity with result.
 * @param parentView            parent/*w w  w.  j a v a 2 s .c o m*/
 * @param label                 label
 * @param pictures              the value are the ids and binary data of the images.
 * @param constraintDescription constraints
 */
public GPictureView(final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode,
        LinearLayout parentView, String label, Map<String, Map<String, String>> pictures,
        String constraintDescription) {
    super(fragmentDetail.getActivity(), attrs);

    thumbnailWidth = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_width);
    thumbnailHeight = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_height);

    mFragmentDetail = fragmentDetail;

    _pictures = pictures;

    PICTURE_VIEW_RESULT = requestCode;

    final FragmentActivity activity = fragmentDetail.getActivity();
    LinearLayout textLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setPadding(10, 5, 10, 5);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(activity);
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    String t = label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription;
    textView.setText(t);
    textView.setTextColor(activity.getResources().getColor(R.color.formcolor));
    textLayout.addView(textView);

    final Button button = new Button(activity);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(15, 5, 15, 5);
    button.setText(R.string.take_picture);
    textLayout.addView(button);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            Intent cameraIntent = new Intent(activity, CameraActivity.class);

            cameraIntent.putExtra(FormUtilities.MAIN_APP_WORKING_DIRECTORY,
                    fragmentDetail.getWorkingDirectory());

            fragmentDetail.startActivityForResult(cameraIntent, requestCode);
        }
    });

    ScrollView scrollView = new ScrollView(activity);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    scrollView.setLayoutParams(scrollLayoutParams);
    scrollView.setHorizontalScrollBarEnabled(true);
    scrollView.setOverScrollMode(HorizontalScrollView.OVER_SCROLL_ALWAYS);
    parentView.addView(scrollView);

    imageLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    imageLayout.setLayoutParams(imageLayoutParams);
    imageLayout.setPadding(15, 5, 15, 5);
    imageLayout.setOrientation(LinearLayout.HORIZONTAL);
    imageLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    scrollView.addView(imageLayout);

    updateValueForm();
    try {
        refresh(activity);
    } catch (Exception e) {
        //GPLog.error(this, null, e);
        e.printStackTrace();
        Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }
}

From source file:com.ekuater.labelchat.ui.fragment.userInfo.HeaderFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Activity activity = getActivity();
    assert activity != null;
    mFrameLayout = new FrameLayout(activity);

    mCover = onCoverView(inflater, mFrameLayout);

    mHeader = onCreateHeaderView(inflater, mFrameLayout);
    mHeaderHeader = mHeader.findViewById(android.R.id.title);
    mHeaderBackground = mHeader.findViewById(android.R.id.background);
    assert mHeader.getLayoutParams() != null;
    mHeaderHeight = mHeader.getLayoutParams().height;

    mFakeHeader = new Space(activity);
    mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight));

    View content = onCreateContentView(inflater, mFrameLayout);
    if (content instanceof RelativeLayout) {
        isListViewEmpty = true;/*w w  w  .  j  a  va 2  s .co m*/

        final ListView listView = (ListView) content.findViewById(R.id.list);
        listView.addHeaderView(mFakeHeader);
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScrollStateChanged(absListView, scrollState);
                }
            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount);
                }

                if (isListViewEmpty) {
                    scrollHeaderTo(0);
                } else {
                    final View child = absListView.getChildAt(0);
                    assert child != null;
                    scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight);
                }
            }
        });
    } else {

        // Merge fake header view and content view.
        final LinearLayout view = new LinearLayout(activity);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setOrientation(LinearLayout.VERTICAL);
        view.addView(mFakeHeader);
        view.addView(content);

        // Put merged content to ScrollView
        final NotifyingScrollView scrollView = new NotifyingScrollView(activity);
        scrollView.addView(view);
        scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() {
            @Override
            public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
                scrollHeaderTo(-t);
            }
        });
        content = scrollView;
    }

    mFrameLayout.addView(content);
    mFrameLayout.addView(mHeader);
    if (mCover != null) {
        mFrameLayout.addView(mCover);
    }
    // Post initial scroll
    mFrameLayout.post(new Runnable() {
        @Override
        public void run() {
            scrollHeaderTo(0, true);
        }
    });

    return mFrameLayout;
}