4

I have a small problem in this case in my app I set default Portrait.But now this time i want show Portrait and landScape in Tabs not only Mobile phone .In mobile phones show only Portrait(Force Update to Portrait).

I followed this link but I am getting this error and i dd't understand how can we create folders where can we place the data. I followed this link: but i didn't get

Android: allow portrait and landscape for tablets, but force portrait on phone?

Lavaraju
  • 2,614
  • 7
  • 29
  • 49

1 Answers1

1

1.Go to the Android folder inside your RN Project,add values-sw600dp and values-xlarge to the following path:

android/app/src/main/res/values-sw600dp
android/app/src/main/res/values-xlarge

then add bools.xml to values,values-sw600dp,values-xlarge. the result:

enter image description here

2.Add code to MainActivity.java in the path android/app/src/main/java/com/[your project name]/MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getResources().getBoolean(R.bool.portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}
ufxmeng
  • 2,570
  • 1
  • 13
  • 14
  • Main Activity or Main Application.Java Which file inside add oncreate methode – Lavaraju Aug 14 '17 at 04:10
  • But I have get an Error – Lavaraju Aug 14 '17 at 05:28
  • MainActivity.java:21: error: cannot find symbol setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ^ symbol: variable ActivityInfo location: class MainActivity 2 errors :app:compileDebugJavaWithJavac FAILED – Lavaraju Aug 14 '17 at 05:29
  • How Can I Solve this – Lavaraju Aug 14 '17 at 05:29
  • This is the full code of the [MainActivity.java](https://pastebin.com/xHs9XMTd), make sure you just paste the code in the right place. – ufxmeng Aug 14 '17 at 08:30
  • check out this [Repo](https://github.com/ufxmeng/ScreenOrientation) to see if it works on your computer. – ufxmeng Aug 14 '17 at 09:33
  • when i was check in my mobile it's shoing portrait and I pad also Portrait not showing Landscape – Lavaraju Aug 14 '17 at 09:50
  • how can Modify the Design Changes getting Portrait . When i was Getting Portrait LandScape getting few Design Issues Above Case based Is it possible Change Design Issues. How is is possible – Lavaraju Aug 14 '17 at 10:25
  • Now Agian Getting Error error: cannot find symbol protected void onCreate(Bundle savedInstanceState) { ^ symbol: class Bundle location: class MainActivity 1 error :app:compileReleaseJavaWithJavac FAILED – Lavaraju Aug 14 '17 at 10:42
  • Open Android studio to auto import all the reference, or just copy them from my repo – ufxmeng Aug 14 '17 at 10:46
  • OKAy I fixed My Issue But When I was Check in Tab it have some Design Issues how Can i fit in Only Or change in Tab please give an suggestion – Lavaraju Aug 14 '17 at 10:49
  • in This based Up on How can i Solve SplitView on Tablet or I pad not Phones – Lavaraju Aug 16 '17 at 12:17
  • 1
    The imports you need to add to the top of the `MainActivity.java` are: `import android.content.pm.ActivityInfo;` and `import android.os.Bundle;`. It took @faddah and I a little while to figure that out. – andersryanc Oct 26 '18 at 23:14