Android App should visible in playstore for normal screen devices as well as tablets and should appear perfect in both (screen resolution)

回眸只為那壹抹淺笑 提交于 2019-12-24 12:02:13

问题


I have recently published android app (sdk version 4.2) in playstore. My requirement is that - this app should be visible in playstore on both - large screen devices (including Samsung Galaxy Tab 2 p3100), as well as normal screen devices. I also want my app to be displayed in devices (with version 2.2 - 4.2).

This is the code snippet, I was suggested for fulfilment of my requirement.

 <supports-screens
   android:smallScreens="true"
   android:normalScreens="true"
   android:largeScreens="true"        
   android:anyDensity="true" 
   android:xlargeScreens="true"
/>

<uses-sdk android:minSdkVersion="8"
    />

There are two cases, depending on the above code.

  1. When I include the above code in manifest.xml

    Including above code in manifest seems to help me in fulfilling my requirement of making my app visible in market for both tablet and small screen devices. But, in that case, the app screens covers only half screen size of tablet, when downloaded from playstore / market as well as it is displayed in a similar manner (covering half screen part) while debugging in tablet.

  2. When I don't include the above code in manifest.xml

    Not including the above code in manifest, seems to work perfect while debugging the app, as the all screens of the app, are displayed perfectly on normal screen devices (phones) as well as on large / x-large screen devices (tablets), but only in case of debugging. The app becomes invisible in playstore for the tablets.

So, both the cases aren't the solution for my requirement.

permissions and features in manifest as below

<uses-feature android:name="android.hardware.touchscreen" android:required="false" /> 
<uses-feature android:name="android.hardware.telephony" android:required="false" /> 
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> 
<uses-feature android:name="android.hardware.camera" android:required="false" /> 
<uses-permission android:name="android.permission.READ_CONTACTS" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.VIBRATE" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.RECORD_VIDEO" /> 
<uses-permission android:name="android.permission.CAMERA" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.GET_TASKS" /> 
<uses-permission android:name="android.permission.RECORD_AUDIO" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 

And here is one of my layout (xml), that consumes only half screen-size when debugging on tablet.

   <?xml version="1.0" encoding="utf-8"?>
   <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:fillViewport="true">

      <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/rl"
        android:background="#000000"
        android:focusableInTouchMode="true">

         <LinearLayout
           android:layout_width="fill_parent"
           android:layout_height="40dp"
           android:gravity="center_vertical"
           android:orientation="horizontal"
           android:background="#0074AF">

            <LinearLayout
               android:paddingLeft="5px"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:gravity="center_vertical"
               android:layout_gravity="center_vertical"
               android:orientation="horizontal"
               android:weightSum="10">

                <TextView android:id="@+id/label"
                  android:layout_weight="8.8"
                  android:layout_marginLeft="5dip"
                  android:textSize="22sp"
                  android:textStyle="bold"
                  android:layout_width="wrap_content"
                  android:textColor="#ffffff"
                  android:gravity="center_vertical"
                  android:layout_gravity="center_vertical"
                  android:text="@string/login"
                  android:layout_height="wrap_content"/>

                   <TextView android:id="@+id/version_no"
                     android:layout_weight="1.2"
                     android:textSize="14sp"
                     android:textStyle="bold"
                     android:layout_width="wrap_content"
                     android:textColor="#222222"
                     android:gravity="center_vertical"
                     android:layout_gravity="center_vertical"
                     android:text="@string/version"
                     android:layout_height="wrap_content"/>

             </LinearLayout>
         </LinearLayout>

         <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginTop="45dp"
            android:background="@drawable/round_borders"
            android:orientation="vertical"
            android:paddingTop="10dp" >

             <TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:paddingBottom="0dp"
              android:paddingTop="0dp"
              android:textColor="#000000"
              android:textSize="20px"
              android:text="Username*"
              android:id="@+id/user"/>

             <EditText
               android:id="@+id/name"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:layout_marginBottom="2dp"
               android:paddingBottom="0dp"
               android:paddingTop="0dp"
               android:singleLine="true"
             />

             <TextView
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:layout_marginBottom="5dp"
               android:paddingBottom="0dp"
               android:paddingTop="0dp"
               android:textColor="#000000"
               android:textSize="20px"
               android:text="Password*"
               android:id="@+id/pswd" />

             <EditText
              android:id="@+id/pass"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:paddingBottom="0dp"
              android:paddingTop="0dp"
              android:singleLine="true"
              android:password="true"
             />

             <TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:paddingBottom="0dp"
              android:paddingTop="0dp"
              android:textColor="#000000"
              android:textSize="20px"
              android:text="AccountId*" />

            <EditText
              android:id="@+id/accid"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="10dp"
              android:paddingBottom="0dp"
              android:paddingTop="0dp"
              android:inputType="date"
              android:singleLine="true"
             />

             <CheckBox android:id="@+id/check1"
               android:layout_width="fill_parent"
               android:textColor="#000000"
               android:layout_height="wrap_content"
               android:text="@string/remember_me" />

             <LinearLayout
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:orientation="horizontal"
               >

             <Button
               style="@style/RedButtons"
               android:layout_width="270dip"
               android:layout_height="50dip"
               android:layout_marginTop="10dp"
               android:gravity="center"
               android:paddingBottom="3dp"
               android:paddingTop="3dp"
               android:id="@+id/login"
               android:text="@string/login"
               android:textSize="20sp" />

             <Button
               style="@style/RedButtons"
               android:layout_width="0dip"
               android:layout_height="0dip"
               android:layout_marginTop="10dp"
               android:layout_marginLeft="70px"
               android:gravity="center"
               android:paddingBottom="3dp"
               android:paddingTop="3dp"
               android:id="@+id/exit"
               android:text="@string/exit"
               android:visibility="gone" />

            </LinearLayout>

            <LinearLayout 
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              android:layout_marginBottom="5dp"
              android:paddingBottom="0dp"
              android:paddingTop="0dp"
              android:orientation="vertical">

            <TextView
              android:id="@+id/new_user_txt"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"  
              android:textColor="#000000"
              android:textSize="16sp"
            />

        </LinearLayout>
     </LinearLayout>
  </RelativeLayout>
 </ScrollView>

That works fine while debugging in both tablet and phone, the screens also appear fine, when I remove the code snippet of supports-screens and uses-sdk tags from the manifest.xml. But, that's not the actual solution (as the app will be hidden in playstore, in that case), I guess.

Please, let me know, what can be done in order to get rid off this problem.


回答1:


The zooming behavior is known as "screen compatibility mode". Google recommends changing your layout not to require this mode. Then you can keep your <supports-screens> element the way you have it.

I haven't tried this, but it seems like the largestWidthLimitDp attribute could be used to force the use of screen compatibility mode for larger devices.

<supports-screens
    android:largestWidthLimitDp="320"
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"        
    android:xlargeScreens="true"/>



回答2:


its working for me perfiectly

<compatible-screens  
 android:smallScreens="true"
 android:normalScreens="true"
 android:largeScreens="true"
 android:anyDensity="true"
 /> 

and define minsdk version as 1 (ie. for all version of devices)

<uses-sdk android:minSdkVersion="1"/>

if your apps doesnot support in android version less than 8 then use this code in your splashscreen activity to prevent from crash the apps

if( Integer.parseInt(android.os.Build.VERSION.SDK) < 8){
            Toast.makeText(getApplicationContext(), "Please upgrade your phone to 2.2+", Toast.LENGTH_LONG).show();
          }



回答3:


This code should work for you

  <supports-screens
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"        
  />

 <uses-sdk android:minSdkVersion="3"/>


来源:https://stackoverflow.com/questions/16621642/android-app-should-visible-in-playstore-for-normal-screen-devices-as-well-as-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!