Example usage for android.widget LinearLayout VERTICAL

List of usage examples for android.widget LinearLayout VERTICAL

Introduction

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

Prototype

int VERTICAL

To view the source code for android.widget LinearLayout VERTICAL.

Click Source Link

Usage

From source file:com.ab.view.sliding.AbSlidingTabView2.java

public AbSlidingTabView2(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new AbHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout/*  ww  w.  ja  va 2 s  .c  o m*/
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        Log.e(TAG, "AbSlidingTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            if (D)
                Log.d(TAG, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            if (D)
                Log.d(TAG, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            if (D)
                Log.d(TAG, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            if (D)
                Log.d(TAG, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:eu.geopaparazzi.library.forms.views.GPictureView.java

/**
 * @param noteId                the id of the note this image belows to.
 * @param fragmentDetail        the fragment detail  to use.
 * @param attrs                 attributes.
 * @param requestCode           the code for starting the activity with result.
 * @param parentView            parent// w  ww .j av  a 2  s .c  om
 * @param key                   key
 * @param value                 in case of pictures, the value are the ids of the image, semicolonseparated.
 * @param constraintDescription constraints
 */
public GPictureView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs,
        final int requestCode, LinearLayout parentView, String key, String value,
        String constraintDescription) {
    super(fragmentDetail.getActivity(), attrs);

    _value = value;

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

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

    final Button button = new Button(activity);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_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) {
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
            double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences);

            String imageName = ImageUtilities.getCameraImageName(null);
            Intent cameraIntent = new Intent(activity, CameraActivity.class);
            cameraIntent.putExtra(LibraryConstants.PREFS_KEY_CAMERA_IMAGENAME, imageName);
            cameraIntent.putExtra(LibraryConstants.DATABASE_ID, noteId);
            if (gpsLocation != null) {
                cameraIntent.putExtra(LibraryConstants.LATITUDE, gpsLocation[1]);
                cameraIntent.putExtra(LibraryConstants.LONGITUDE, gpsLocation[0]);
                cameraIntent.putExtra(LibraryConstants.ELEVATION, gpsLocation[2]);
            }
            fragmentDetail.startActivityForResult(cameraIntent, requestCode);
        }
    });

    ScrollView scrollView = new ScrollView(activity);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    scrollView.setLayoutParams(scrollLayoutParams);
    parentView.addView(scrollView);

    imageLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    imageLayout.setLayoutParams(imageLayoutParams);
    imageLayout.setOrientation(LinearLayout.HORIZONTAL);
    scrollView.addView(imageLayout);

    try {
        refresh(activity);
    } catch (Exception e) {
        GPLog.error(this, null, e);
    }
}

From source file:com.lxh.util.pullview.AbSlidingPlayView.java

/**
 * ???View./*from w w w .j a v  a  2 s .co m*/
 *
 * @param context
 *            the context
 */
public void initView(Context context) {
    this.context = context;
    navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    this.setOrientation(LinearLayout.VERTICAL);

    RelativeLayout mRelativeLayout = new RelativeLayout(context);

    mViewPager = new AbInnerViewPager(context);
    // ViewPager,fragmentsetId()id
    mViewPager.setId(1985);
    // 
    mNavLayoutParent = new LinearLayout(context);
    mNavLayoutParent.setPadding(0, 5, 0, 5);
    navLinearLayout = new LinearLayout(context);
    navLinearLayout.setPadding(15, 1, 15, 1);
    navLinearLayout.setVisibility(View.INVISIBLE);
    mNavLayoutParent.addView(navLinearLayout,
            new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mRelativeLayout.addView(mViewPager, lp1);

    RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    mRelativeLayout.addView(mNavLayoutParent, lp2);
    addView(mRelativeLayout,
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    displayImage = FileUtil.getBitmapFromSrc("image/play_display.png");
    hideImage = FileUtil.getBitmapFromSrc("image/play_hide.png");

    mListViews = new ArrayList<View>();
    mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews);
    mViewPager.setAdapter(mAbViewPagerAdapter);
    mViewPager.setFadingEdgeLength(0);
    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            makesurePosition();
            onPageSelectedCallBack(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            onPageScrolledCallBack(position);
        }

    });

}

From source file:net.peterkuterna.android.apps.devoxxsched.ui.PullToRefreshListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a PullToRefreshListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty./*from  ww w .  ja  v a  2 s . co  m*/
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(context);
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    PullToRefreshListView lv = new PullToRefreshListView(context);
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    return root;
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context//from   w w  w  . j  av  a 2  s. co  m
 * @param attrs the attrs
 */
public ESSlidingSmoothTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new ESHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        ESLogUtil.e(ESSlidingSmoothTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            ESLogUtil.d(ESSlidingSmoothTabView.class, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            ESLogUtil.d(ESSlidingSmoothTabView.class, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:edu.byu.scriptures.controller.fragment.RestartableListFragment.java

/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 *
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 *//*from w  w  w.ja  v  a2  s . co  m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    tv.setTextSize(18);

    int padding = ((MainActivity) getActivity()).getMetricsManager().dpToRawPixels(20);

    tv.setPadding(padding, 0, padding, 0);
    tv.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_normal));
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ListView lv = new ListView(getActivity());
    int troughPadding = ((MainActivity) getActivity()).getMetricsManager().getTroughPadding();

    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setPadding(troughPadding, 0, troughPadding, 0);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context/*from  ww w  .j a  v a2 s  .com*/
 * @param attrs the attrs
 */
public AbSlidingSmoothTabView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.setOrientation(LinearLayout.VERTICAL);
    this.setBackgroundColor(Color.rgb(255, 255, 255));

    mTabScrollView = new AbHorizontalScrollView(context);
    mTabScrollView.setHorizontalScrollBarEnabled(false);
    mTabLayout = new LinearLayout(context);
    mTabLayout.setOrientation(LinearLayout.HORIZONTAL);
    mTabLayout.setGravity(Gravity.CENTER);
    //mTabLayout
    mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    //Tab?
    tabItemList = new ArrayList<TextView>();
    tabItemTextList = new ArrayList<String>();

    this.addView(mTabScrollView, layoutParamsFW);

    //?
    mTabImg = new ImageView(context);
    this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight));

    //View?
    mViewPager = new ViewPager(context);
    //ViewPager,setId()id
    mViewPager.setId(1985);
    pagerItemList = new ArrayList<Fragment>();

    this.addView(mViewPager, layoutParamsFF);

    //?FragmentActivity
    if (!(this.context instanceof FragmentActivity)) {
        AbLogUtil.e(AbSlidingSmoothTabView.class,
                "AbSlidingSmoothTabView?context,FragmentActivity");
    }

    FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbOnScrollListener() {

        @Override
        public void onScrollToRight() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToRight");
        }

        @Override
        public void onScrollToLeft() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollToLeft");
        }

        @Override
        public void onScrollStoped() {
            AbLogUtil.d(AbSlidingSmoothTabView.class, "onScrollStoped");
        }

        @Override
        public void onScroll(int arg1) {
            scrollX = arg1;
            View view = mTabLayout.getChildAt(mSelectedTabIndex);
            int toX = view.getLeft() - scrollX;

            AbLogUtil.d(AbSlidingSmoothTabView.class, "X" + startX + "to" + toX);
            imageSlide(mTabImg, startX, toX, 0, 0);
            startX = toX;
        }
    });
}

From source file:com.viewpagerindicator.TabMovablePageIndicator.java

public TabMovablePageIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    mScreenWidth = getScreenDisplayMetrics().widthPixels;
    setHorizontalScrollBarEnabled(false);

    mMainBox = new LinearLayout(context);
    mMainBox.setOrientation(LinearLayout.VERTICAL);
    mMainBox.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT));

    mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle);
    mMainBox.addView(mTabLayout, new LinearLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT, 1));

    mIndicator = new ImageView(context);
    LinearLayout.LayoutParams indicatorLp = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    mMainBox.addView(mIndicator, indicatorLp);

    addView(mMainBox, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}

From source file:org.mariotaku.twidere.fragment.PullToRefreshListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//from  ww w .  j  ava  2s  .  c o m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new HoloProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final PullToRefreshListView plv = new PullToRefreshListView(context);
    plv.setOnRefreshListener(this);
    mPullToRefreshListView = plv;

    final ListView lv = plv.getRefreshableView();
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(plv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.dwdesign.tweetings.fragment.PullToRefreshListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//from   w  w  w  .  ja v  a  2  s  . co m
 * 
 * <p>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final PullToRefreshListView plv = new PullToRefreshListView(context);
    plv.setOnRefreshListener(this);
    mPullToRefreshListView = plv;

    final ListView lv = plv.getRefreshableView();
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(plv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}