我正在开发一个RTL应用程序,它使用TabLayout(可滚动模式)和ViewPager来滑动片段页面! 在针对不同的api进行测试后,我注意到api 17和18中TabLayout的异常行为!
那么我想我的xml或我的代码可能有问题! 我决定使用第三方库来避免这个问题,但同样的结果发生了!
在调查了第三方库所有者之后,我们注意到库和TabLayout都使用HorizontalScrollView,这可能就是问题!
调查链接: https : //github.com/ogaclejapan/SmartTabLayout/issues/107
请指导我解决这个问题!
有没有办法使用在api 23里面的api 17和18的HorizontalScrollView?
重现问题的步骤:
困难的方法:创建一个新项目,并在其中使用以下xml和代码,并在api 17或18模拟器上运行它。
buildToolsVersion“23.0.2”
compileSdkVersion 23
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layoutDirection="rtl" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="ir.heandshe.testinghorizontal.MainActivity"> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" app:tabMode="scrollable"/> </RelativeLayout>MainActivity.java:
public class MainActivity extends AppCompatActivity { private TabLayout tabs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabs = (TabLayout) findViewById(R.id.tabs); for (int i=0 ; i<=10;i++) { tabs.addTab(tabs.newTab().setText("test " + i)); } } }简单方法:使用以下链接并克隆库并在模拟器17或18上运行演示! (演示应用程序中的RTL部分) - > https://github.com/ogaclejapan/SmartTabLayout
发生了什么 :
1 - 标签向错误的方向移动
2 - 他们不会填充ViewPort! 在某些情况下,他们从屏幕中间开始! :((
您认为正确的行为应该是:正常的行为就像在api 19+中工作一样
请确保在RTL模式下测试它! LTR没问题!
如何从android SDK源创建库?
Im developing an RTL app which uses TabLayout (Scrollable mode) and ViewPager for sliding fragment pages ! after testing it for different api i've notice abnormal behavier of TabLayout in api 17 and 18!
then i think maybe there was something wrong with my xml or my code! i decide to use a third party library to avoid this issue but same result happend!
after investigating with that third party library owner we notice that both the library and TabLayout use HorizontalScrollView and maybe thats the problem!
investigation link : https://github.com/ogaclejapan/SmartTabLayout/issues/107
please guide me to resolve this!
is there a way to use HorizontalScrollView which is inside api 23 for api 17 and 18 ?
Steps to reproduce the problem :
Hard way : create a new project and inside that use following xml and code and run it on api 17 or 18 emulator.
buildToolsVersion "23.0.2"
compileSdkVersion 23
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layoutDirection="rtl" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="ir.heandshe.testinghorizontal.MainActivity"> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" app:tabMode="scrollable"/> </RelativeLayout>MainActivity.java :
public class MainActivity extends AppCompatActivity { private TabLayout tabs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabs = (TabLayout) findViewById(R.id.tabs); for (int i=0 ; i<=10;i++) { tabs.addTab(tabs.newTab().setText("test " + i)); } } }Easy way : use following link and clone the library and run demo on emulator 17 or 18! (RTL section in demo app) --> https://github.com/ogaclejapan/SmartTabLayout
What happened :
1 - Tabs move in wrong direction
2 - They wont fill the ViewPort! in some cases they start from the middle of the screen! :((
What you think the correct behavior should be :normal behavier is to work like when its work in api 19+
please be sure that you test it in RTL mode ! LTR has no problem!
How can I create a library from android SDK source?
最满意答案
根据这个问题 ,这是ViewPager库中的一个错误 有一个技巧可以解决这个问题,但这不是最好的方法
在你的TabLayout xml中添加以下行:
android:layoutDirection="ltr"这将阻止TabLayout在RTL设备中进行镜像,并且它将与ViewPager方向匹配。
PS我在api 25和支持库25.1.0上遇到同样的问题。 这个技巧解决了它。
According to this issue, it's a bug in ViewPager library There is a trick to solve this but it's not the best way
In your TabLayout xml add this line:
android:layoutDirection="ltr"This will prevent TabLayout from mirroring in RTL devices and it will match ViewPager direction.
P.S. I have same problem on api 25 and support library 25.1.0. This trick solved it.
具有rtl布局方向的api 17和18的Tablayout问题(Tablayout issue for api 17 and 18 with rtl layout direction)我正在开发一个RTL应用程序,它使用TabLayout(可滚动模式)和ViewPager来滑动片段页面! 在针对不同的api进行测试后,我注意到api 17和18中TabLayout的异常行为!
那么我想我的xml或我的代码可能有问题! 我决定使用第三方库来避免这个问题,但同样的结果发生了!
在调查了第三方库所有者之后,我们注意到库和TabLayout都使用HorizontalScrollView,这可能就是问题!
调查链接: https : //github.com/ogaclejapan/SmartTabLayout/issues/107
请指导我解决这个问题!
有没有办法使用在api 23里面的api 17和18的HorizontalScrollView?
重现问题的步骤:
困难的方法:创建一个新项目,并在其中使用以下xml和代码,并在api 17或18模拟器上运行它。
buildToolsVersion“23.0.2”
compileSdkVersion 23
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layoutDirection="rtl" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="ir.heandshe.testinghorizontal.MainActivity"> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" app:tabMode="scrollable"/> </RelativeLayout>MainActivity.java:
public class MainActivity extends AppCompatActivity { private TabLayout tabs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabs = (TabLayout) findViewById(R.id.tabs); for (int i=0 ; i<=10;i++) { tabs.addTab(tabs.newTab().setText("test " + i)); } } }简单方法:使用以下链接并克隆库并在模拟器17或18上运行演示! (演示应用程序中的RTL部分) - > https://github.com/ogaclejapan/SmartTabLayout
发生了什么 :
1 - 标签向错误的方向移动
2 - 他们不会填充ViewPort! 在某些情况下,他们从屏幕中间开始! :((
您认为正确的行为应该是:正常的行为就像在api 19+中工作一样
请确保在RTL模式下测试它! LTR没问题!
如何从android SDK源创建库?
Im developing an RTL app which uses TabLayout (Scrollable mode) and ViewPager for sliding fragment pages ! after testing it for different api i've notice abnormal behavier of TabLayout in api 17 and 18!
then i think maybe there was something wrong with my xml or my code! i decide to use a third party library to avoid this issue but same result happend!
after investigating with that third party library owner we notice that both the library and TabLayout use HorizontalScrollView and maybe thats the problem!
investigation link : https://github.com/ogaclejapan/SmartTabLayout/issues/107
please guide me to resolve this!
is there a way to use HorizontalScrollView which is inside api 23 for api 17 and 18 ?
Steps to reproduce the problem :
Hard way : create a new project and inside that use following xml and code and run it on api 17 or 18 emulator.
buildToolsVersion "23.0.2"
compileSdkVersion 23
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layoutDirection="rtl" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="ir.heandshe.testinghorizontal.MainActivity"> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="?android:attr/actionBarSize" app:tabMode="scrollable"/> </RelativeLayout>MainActivity.java :
public class MainActivity extends AppCompatActivity { private TabLayout tabs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabs = (TabLayout) findViewById(R.id.tabs); for (int i=0 ; i<=10;i++) { tabs.addTab(tabs.newTab().setText("test " + i)); } } }Easy way : use following link and clone the library and run demo on emulator 17 or 18! (RTL section in demo app) --> https://github.com/ogaclejapan/SmartTabLayout
What happened :
1 - Tabs move in wrong direction
2 - They wont fill the ViewPort! in some cases they start from the middle of the screen! :((
What you think the correct behavior should be :normal behavier is to work like when its work in api 19+
please be sure that you test it in RTL mode ! LTR has no problem!
How can I create a library from android SDK source?
最满意答案
根据这个问题 ,这是ViewPager库中的一个错误 有一个技巧可以解决这个问题,但这不是最好的方法
在你的TabLayout xml中添加以下行:
android:layoutDirection="ltr"这将阻止TabLayout在RTL设备中进行镜像,并且它将与ViewPager方向匹配。
PS我在api 25和支持库25.1.0上遇到同样的问题。 这个技巧解决了它。
According to this issue, it's a bug in ViewPager library There is a trick to solve this but it's not the best way
In your TabLayout xml add this line:
android:layoutDirection="ltr"This will prevent TabLayout from mirroring in RTL devices and it will match ViewPager direction.
P.S. I have same problem on api 25 and support library 25.1.0. This trick solved it.
发布评论