Tablelayout RTL和ViewPager滑动LTR

时间:2019-05-18 07:27:21

标签: kotlin-android-extensions

如何在布局中将滑动Viewpager rtl更改为ltr? 我的apk支持波斯语。在我的tablayout支持rtl中,我需要在视图寻呼机中滑动ltr。如何更改?

<class Product_List : AppCompatActivity() {

    var tabLayout:TabLayout?=null
    var viewPager:ViewPager?=null
    override fun onCreate(savedInstanceState: Bundle?) {
     super.onCreate(savedInstanceState)
        setContentView(R.layout.product__list)
        setSupportActionBar(toolbar_Product)
        supportActionBar?.setDisplayHomeAsUpEnabled(true)
        tabLayout=findViewById(R.id.product_list_table)
        viewPager=findViewById(R.id.product_list_ViewPage)
        tabLayout!!.addTab(tabLayout!!.newTab().setText("کالای دیجیتال"))
        tabLayout!!.addTab(tabLayout!!.newTab().setText("کتاب"))
        tabLayout!!.addTab(tabLayout!!.newTab().setText("خودرو"))
        tabLayout!!.addTab(tabLayout!!.newTab().setText("ورزشی"))
        tabLayout!!.tabGravity = TabLayout.GRAVITY_FILL
        val adapter= MyAdapter(this, supportFragmentManager, tabLayout!!.tabCount)
        viewPager!!.adapter=adapter
        viewPager!!.addOnPageChangeListener(TabLayout.TabLayoutOnPageChangeListener(tabLayout))
        tabLayout!!.addOnTabSelectedListener(object :TabLayout.OnTabSelectedListener{
            override fun onTabSelected(tab:TabLayout.Tab) {
                viewPager!!.currentItem =tab.position
            }
            override fun onTabUnselected(tab:TabLayout.Tab) {}
            override fun onTabReselected(tab:TabLayout.Tab) {} })}
    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
        var id = item?.itemId
        if (id==android.R.id.home)
            onBackPressed()
        return super.onOptionsItemSelected(item)
    }
}
>

0 个答案:

没有答案