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

The following examples show how to use androidx.viewpager.widget.ViewPager#getLayoutParams() . 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: CPUBoostActivity.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tablayout);

    TabLayout tabLayout = findViewById(R.id.tabLayoutID);
    ViewPager viewPager = findViewById(R.id.viewPagerID);

    PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager());
    if (CPUBoost.getInstance().supported() || CPUInputBoost.getInstance().supported()) {
        adapter.AddFragment(new CPUBoostFragment(), getString(R.string.cpu_boost));
    }
    if (VoxPopuli.hasVoxpopuliTunable()) {
        adapter.AddFragment(new PowerHalFragment(), getString(R.string.powerhal));
    }
    if (StuneBoost.supported()) {
        adapter.AddFragment(new StuneBoostFragment(), getString(R.string.stune_boost));
    }

    viewPager.setAdapter(adapter);
    tabLayout.setVisibility(View.VISIBLE);
    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) viewPager.getLayoutParams();
    lp.bottomMargin += 150;
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 2
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 3
Source File: EmoticonControlPanel.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
public void initialize(int totalHeight) {
    ViewPager emoticonViewPager = findViewById(R.id.bottom_emoticon);
    int height = totalHeight - getResources().getDimensionPixelSize(R.dimen.bottom_emoticon_tab_height);
    emoticonViewPager.getLayoutParams().height = height;
    emoticonViewPager.setAdapter(new EmoticonParentAdapter(getContext(), height));
    TabLayout tabLayout = findViewById(R.id.bottom_emoticon_tab);
    tabLayout.setupWithViewPager(emoticonViewPager);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
}
 
Example 4
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 5
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);
}