0

I'm developing android app and using eclipse. I run this app on two tabs and the screen size id ok with one tab, but in other tab the screen size won't fit to the device and icons are also larger. i'm a beginner to this and is there any way to solve this using following way ?

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" /> 

and <supports-screens android:xlargeScreens="true"/>

do i need to change Manifest file ? or is there any changes to be made to layouts?
this is one of my xml

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">

        <HorizontalScrollView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true">    


      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/container1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"    
        android:orientation="vertical" 
        android:background="@drawable/background6">


        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="match_parent"
            android:layout_height="1dp" >
        </TableRow>

         <TableRow
            android:id="@+id/tableRow18"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lblNICBRAdvRcpt"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="50dp"            
                android:text="NIC/BR No :"
                android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#515152"/>


            <EditText
                android:id="@+id/txtNICBRAdvRcpt"
                android:layout_width="200dp"
                android:layout_height="wrap_content"           
                android:inputType="textCapCharacters"
                android:tag="txt"           
                android:maxLength="30"
                android:maxLines="1" />

           <TextView
               android:id="@+id/lblCustomerType"
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="30dp"            
                android:text="Customer Type :"
                android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#515152"
                />
            <Spinner
                   android:id="@+id/spinCustomerType"
                   android:layout_width="200dp"
                   android:layout_height="50dp"
                   android:background="@drawable/spnbg" />
<!--some code here -->

         </TableRow>
       </LinearLayout>

     </HorizontalScrollView>

    </ScrollView>
Didu
  • 79
  • 2
  • 11

1 Answers1

0

the screen size won't fit to the device

I'm assuming you mean the width of the layout is bigger then the screen. This may be caused by using fixed sized width components, for example under tableRow18 you have multiple children, each with a fixed width, and fixed margins:

width="150dp" + 
marginLeft="50dp" +
width="200dp" +
width="150dp" +
marginLeft="30dp" +
width="200dp" 
=======
780dp

So if the screen width is less then 780dp, the layout would be bigger then the screen width.

You should try to minimize the use of fixed sizes, and prefer match_parent and wrap_content width values. You can also add android:minWidth= and android:maxWidth= if you need components at least Xdp or at most Xdp size.

If you need to spread your children across the screen width evenly, consider using layout_weights for this.

marmor
  • 27,641
  • 11
  • 107
  • 150
  • I tried to use layout_weights. but still the problem occurs because my whole application screens runs without fitting the screen. I have added a scroll and it solves half of the problem. but it looks like working with lower resolution. Large icons etc..but my problem still not solved. – Didu Oct 17 '17 at 08:21
  • can you add screenshots of how it looks like with the large icons, and how it should look like? this may be related to placing your drawables in the wrong folder, you should usually only use folders with screen attributes like: `res/drawable-xxhdpi` and not `res/drawable` – marmor Oct 17 '17 at 09:12
  • I will try to put screenshots. but only one of my tabs face this problem. other one woks fine. – Didu Oct 17 '17 at 09:54