请提出解决方案.
当我旋转我的片段时,它应该切换到横向模式并显示另一个布局.但是屏幕不会旋转到横向.
我的代码打击:
<activity
android:name=".activites.MainActivity"
android:launchMode="singleInstance"
android:configChanges="keyboardHidden|screenLayout|screenSize|orientation"
/>
Run Code Online (Sandbox Code Playgroud)
这是称为仪表板的主要布局,现在它处于纵向模式:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view=View.inflate(getContext(), R.frag_dashboard,null);
changeview= (ShimmerTextView)view.findViewById(R.id.changeview);
return view;
}
Run Code Online (Sandbox Code Playgroud)
当我旋转屏幕时,这个片段变为横向模式并设置另一个布局,pray_times是新的布局.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(getContext(), "landscape", Toast.LENGTH_SHORT).show();
view=View.inflate(getContext(), R.layout.prayer_times,null);
}
}
Run Code Online (Sandbox Code Playgroud)
我为pray_times创建layout_land