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>
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.