Example usage for android.widget ImageView ImageView

List of usage examples for android.widget ImageView ImageView

Introduction

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

Prototype

public ImageView(Context context) 

Source Link

Usage

From source file:hoahong.facebook.messenger.ui.EmojiView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(getContext());
        if (Utils.isTablet()) {
            gridView.setColumnWidth(Utils.dp(60));
        } else {/*from w w w . j  a  v  a2 s  .c  o  m*/
            gridView.setColumnWidth(Utils.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(localEmojiGridAdapter);
        adapters.add(localEmojiGridAdapter);
    }

    setBackgroundDrawable(
            new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 }));
    pager = new ViewPager(getContext());
    pager.setAdapter(new EmojiPagesAdapter());
    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorColor(0xff33b5e5);
    tabs.setIndicatorHeight(Utils.dpf(2.0f));
    tabs.setUnderlineHeight(Utils.dpf(2.0f));
    tabs.setUnderlineColor(0x66000000);
    tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (EmojiView.this.listener != null) {
                EmojiView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LinearLayout.LayoutParams(Utils.dp(61), LayoutParams.MATCH_PARENT));
    recentsWrap = new FrameLayout(getContext());
    recentsWrap.addView(views.get(0));
    TextView localTextView = new TextView(getContext());
    localTextView.setText("No recent");
    localTextView.setTextSize(18.0f);
    localTextView.setTextColor(-7829368);
    localTextView.setGravity(17);
    recentsWrap.addView(localTextView);
    views.get(0).setEmptyView(localTextView);
    addView(localLinearLayout, new LinearLayout.LayoutParams(-1, Utils.dpf(48.0f)));
    addView(pager);
    loadRecents();
    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:me.cpwc.nibblegram.ui.Components.EmojiView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(getContext());
        if (AndroidUtilities.isTablet()) {
            gridView.setColumnWidth(AndroidUtilities.dp(60));
        } else {//www.  j a  va 2 s  .co  m
            gridView.setColumnWidth(AndroidUtilities.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(localEmojiGridAdapter);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999);
        adapters.add(localEmojiGridAdapter);
    }

    setBackgroundColor(0xff222222);
    pager = new ViewPager(getContext());
    pager.setAdapter(new EmojiPagesAdapter());
    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorColor(0xff33b5e5);
    tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f));
    tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f));
    tabs.setUnderlineColor(0x66000000);
    tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (EmojiView.this.listener != null) {
                EmojiView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT));
    recentsWrap = new FrameLayout(getContext());
    recentsWrap.addView(views.get(0));
    TextView localTextView = new TextView(getContext());
    localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    localTextView.setTextSize(18.0f);
    localTextView.setTextColor(-7829368);
    localTextView.setGravity(17);
    recentsWrap.addView(localTextView);
    views.get(0).setEmptyView(localTextView);
    addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f)));
    addView(pager);
    loadRecents();
    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:com.yahala.ui.Views.StickersView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    loadRecents();//from  ww w. ja v  a 2 s  .  com
    setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] {
            Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666") }));

    emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().stickersCategories);
    pager = new ViewPager(getContext());
    pager.setAdapter(emojiPagerAdapter);
    FileLog.e("EmojiManager.stickersCategories", "" + EmojiManager.getInstance().stickersCategories.size());
    PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(false);
    tabs.setMinimumWidth(OSUtilities.dp(50));
    tabs.setTabPaddingLeftRight(OSUtilities.dp(10));
    tabs.setIndicatorHeight(3);
    //tabs.setTabBackground(Color.parseColor("#FF3f9fe0"));
    tabs.setTabBackground(R.drawable.bar_selector_main);

    tabs.setIndicatorColor(Color.parseColor("#FFffffff"));
    tabs.setDividerColor(Color.parseColor("#ff222222"));
    tabs.setUnderlineHeight(2);
    tabs.setUnderlineColor(Color.parseColor("#ff373737"));

    //tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            if (StickersView.this.listener != null) {
                StickersView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT));
    /* recentsWrap = new FrameLayout(getContext());
     recentsWrap.addView(views.get(0));
     TextView localTextView = new TextView(getContext());
     localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
     localTextView.setTextSize(18.0f);
     localTextView.setTextColor(-7829368);
     localTextView.setGravity(17);
     recentsWrap.addView(localTextView);
     views.get(0).setEmptyView(localTextView);*/
    addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f)));

    addView(pager);

    if (!EmojiManager.getInstance().stickersCategoriesDict.containsKey("recents")
            || EmojiManager.getInstance().stickersCategoriesDict.get("recents").stickers.size() == 0) {
        pager.setCurrentItem(1);
    }
}

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/*from w w  w.  jav a2 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:com.flan.stock.fragment.FragmentNewsYw.java

/**
 * ???//  w  w  w  .j  av  a2  s .co m
 */
private void getTouTiaoData() {

    LayoutParams para = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    ImageView img1 = new ImageView(context);
    img1.setBackgroundResource(R.drawable.img_ipo);
    img1.setLayoutParams(para);
    ImageView img2 = new ImageView(context);
    img2.setBackgroundColor(Color.BLUE);
    img2.setLayoutParams(para);
    toutiaoList = new ArrayList<>();
    toutiaoList.add(img1);
    toutiaoList.add(img2);
}

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  a  v a2s . c  o  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:com.aimfire.intro.IntroductionActivity.java

@SuppressWarnings("deprecation")
public void addDots() {
    dots = new ArrayList<ImageView>();
    LinearLayout dotsLayout = (LinearLayout) findViewById(R.id.dots);

    for (int i = 0; i < NUM_PAGES; i++) {
        ImageView dot = new ImageView(this);
        dot.setImageDrawable(getResources().getDrawable(R.drawable.pager_dot_not_selected));

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);

        params.setMargins(20, 0, 20, 0);
        dotsLayout.addView(dot, params);

        dots.add(dot);//from   w w  w .ja  v  a 2s . com
    }

    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

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

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
}

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

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context// ww w  .  ja v a  2s .  co m
 * @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.yahala.ui.Views.EmojiViewExtra.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    loadRecents();/*w w  w.  j  a  v  a2s .  c o m*/
    setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] {
            Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666") }));

    emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().categories);
    pager = new ViewPager(getContext());
    pager.setOffscreenPageLimit(5);
    pager.setAdapter(emojiPagerAdapter);
    FileLog.e("EmojiManager.emojiGroups", "" + EmojiManager.getInstance().categories.size());
    PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(false);
    tabs.setMinimumWidth(OSUtilities.dp(50));
    tabs.setTabPaddingLeftRight(OSUtilities.dp(10));
    tabs.setIndicatorHeight(3);
    //tabs.setTabBackground(Color.parseColor("#FF3f9fe0"));
    tabs.setTabBackground(R.drawable.bar_selector_main);

    tabs.setIndicatorColor(Color.parseColor("#FFffffff"));
    tabs.setDividerColor(Color.parseColor("#ff222222"));
    tabs.setUnderlineHeight(2);
    tabs.setUnderlineColor(Color.parseColor("#ff373737"));

    //tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            if (EmojiViewExtra.this.listener != null) {
                EmojiViewExtra.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT));
    /* recentsWrap = new FrameLayout(getContext());
     recentsWrap.addView(views.get(0));
     TextView localTextView = new TextView(getContext());
     localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
     localTextView.setTextSize(18.0f);
     localTextView.setTextColor(-7829368);
     localTextView.setGravity(17);
     recentsWrap.addView(localTextView);
     views.get(0).setEmptyView(localTextView);*/
    addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f)));

    addView(pager);

    if (!EmojiManager.getInstance().categoriesDict.containsKey("recents")
            || EmojiManager.getInstance().categoriesDict.get("recents").emojis.size() == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:com.dreamchen.useful.mouserace.view.sliding.AbSlidingSmoothTabView.java

/**
 * Instantiates a new ab sliding smooth tab view.
 *
 * @param context the context//from  ww w. ja va2s. c  om
 * @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).getSupportFragmentManager();
    mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList);
    mViewPager.setAdapter(mFragmentPagerAdapter);
    mViewPager.setOnPageChangeListener(new MyOnPageChangeListener());
    mViewPager.setOffscreenPageLimit(3);

    mTabScrollView.setSmoothScrollingEnabled(true);

    mTabScrollView.setOnScrollListener(new AbHorizontalScrollView.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;
        }
    });
}