Java Code Examples for androidx.viewpager.widget.ViewPager#setLayoutParams()

The following examples show how to use androidx.viewpager.widget.ViewPager#setLayoutParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionBarUtility.java    From Simple-Dilbert with Apache License 2.0 6 votes vote down vote up
public static void toggleActionBar(AppCompatActivity actionBarActivity,
                                   ViewPager viewPager) {
    try {
        if (actionBarActivity == null || actionBarActivity.getSupportActionBar() == null)
            return;
        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) viewPager
                .getLayoutParams();
        if (lp == null)
            return;
        if (actionBarActivity.getSupportActionBar().isShowing()) {
            actionBarActivity.getSupportActionBar().hide();
            lp.topMargin = 0;
            viewPager.setLayoutParams(lp);
        } else {
            actionBarActivity.getSupportActionBar().show();
            lp.topMargin = getActionBarHeightCompat(actionBarActivity);
            viewPager.setLayoutParams(lp);
        }
    } catch (Throwable t) {
        Log.e("DilbertFragmentActivity", "Toggle ActionBar failed", t);
    }
}
 
Example 2
Source File: SmileyView.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    this.context = context;
    setElevation(DimenUtils.dip2px(context, 4));
    size8 = DimenUtils.dip2px(context, 8);
    setOrientation(VERTICAL);
    colorTab = ContextCompat.getColor(context, R.color.bg_primary);
    colorTabSize = ContextCompat.getColor(context, R.color.bg_secondary);

    viewPager = new ViewPager(context);
    viewPager.setLayoutParams(new LayoutParams(LMP, LWC, 1));
    viewPager.addOnPageChangeListener(this);
    dotImageResourseId = R.drawable.dot_bg;
    addView(viewPager);

    dotContainer = new LinearLayout(context);
    dotContainer.setOrientation(LinearLayout.HORIZONTAL);
    dotContainer.setLayoutParams(new LayoutParams(LMP, DimenUtils.dip2px(context, 16)));
    dotContainer.setGravity(Gravity.CENTER_HORIZONTAL);
    addView(dotContainer);

    tabContainer = new LinearLayout(context);
    tabContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabContainer.setGravity(Gravity.CENTER_VERTICAL);
    tabContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.bg_primary));
    tabContainer.setLayoutParams(new LayoutParams(LMP, DimenUtils.dip2px(context, 36)));
    addView(tabContainer);
}
 
Example 3
Source File: MyGuildView.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    this.context = context;
    dotMargine = DimenUtils.dip2px(context, 2);
    containerPaddingTB = DimenUtils.dip2px(context, 8);
    containerPaddingLR = DimenUtils.dip2px(context, 12);

    dotImageResourseId = R.drawable.dot_bg;
    viewPager = new ViewPager(context);
    viewPager.setLayoutParams(new LayoutParams(RMP, RMP));
    viewPager.addOnPageChangeListener(this);
    adapter = new PageAdapter();
    viewPager.setPageTransformer(true, new ScalePageTransformer());
    viewPager.setAdapter(adapter);
    addView(viewPager);

    dotContainer = new LinearLayout(context);
    LayoutParams lp = new LayoutParams(RMP, RWC);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    // 在这儿设置圆点位置
    lp.addRule(CENTER_HORIZONTAL);
    dotContainer.setLayoutParams(lp);
    dotContainer.setOrientation(LinearLayout.HORIZONTAL);
    //dotContainer.setGravity(CENTER_HORIZONTAL);
    dotContainer.setGravity(CENTER_VERTICAL);
    dotContainer.setBackgroundColor(0x7f333333);
    dotContainer.setPadding(containerPaddingLR, containerPaddingTB, containerPaddingLR, containerPaddingTB);
    addView(dotContainer);

    mAutoPlayTask = new AutoPlayTask(this);
}
 
Example 4
Source File: ViewPagerPageManager.java    From Paginize with MIT License 5 votes vote down vote up
private void initViewPager(Context context) {
  mViewPager = new ViewPager(context);
  mViewPager.setLayoutParams(new ViewGroup.LayoutParams(
      ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.MATCH_PARENT));

  mPagerAdapter = new InnerPagePagerAdapter();
  mViewPager.setAdapter(mPagerAdapter);
  mViewPager.addOnPageChangeListener(new InnerPageChangeListener());

  getContainerView().addView(mViewPager);
}
 
Example 5
Source File: EmojiLayoutParams.java    From openboard with GNU General Public License v3.0 4 votes vote down vote up
public void setPagerProperties(final ViewPager vp) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) vp.getLayoutParams();
    lp.height = mEmojiKeyboardHeight;
    lp.bottomMargin = mEmojiPagerBottomMargin;
    vp.setLayoutParams(lp);
}
 
Example 6
Source File: EmojiLayoutParams.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 4 votes vote down vote up
public void setPagerProperties(final ViewPager vp) {
    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) vp.getLayoutParams();
    lp.height = mEmojiKeyboardHeight;
    lp.bottomMargin = mEmojiPagerBottomMargin;
    vp.setLayoutParams(lp);
}