brux
brux

Reputation: 3230

Android xml layout problem with small views

Im trying to make this layout look better. Everything was find until I added to the manifest. Since then everything has kinda shrunk. The reason I added the uses minSdk directive is to allow qvga devices such as the wildfireto run my app.

The image will not fill the space, its rather small in the middle or its LinearLayout Parent.

Also the gallery at the bottom is very small making it difficult to click on items in the gallery.

Anybody got some suggestions?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">

<LinearLayout
android:id="@+id/header"
android:layout_alignParentTop="true"
android:layout_width="fill_parent"
android:layout_height="100px"
android:background="#ffffff">
<TextView
android:text="header"
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginLeft="10px"></TextView>
</LinearLayout>

<LinearLayout
android:id="@+id/footer"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/examplegallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" />
</LinearLayout>

<LinearLayout
android:id="@+id/body"
android:layout_below="@id/header"
android:layout_above="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Whatever your body is -->
    <ImageView 
    android:src="@drawable/icon" 
    android:layout_width="fill_parent" 
    android:layout_gravity="center"
    android:id="@+id/imageView1"
    android:layout_height="120dp"></ImageView>

    </LinearLayout>

    <TableRow android:layout_height="wrap_content" 
        android:layout_width="wrap_content" android:id="@+id/tableRow1" android:layout_above="@+id/scrollView1" android:layout_alignParentLeft="true">

    <TextView
    android:text="price"
    android:id="@+id/price"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#09bade"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:layout_marginRight="20px"
    android:layout_marginLeft="10px"
    ></TextView>
    <TextView
    android:text="quickcode"
    android:id="@+id/quickcode"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#ff8400"
    android:layout_marginRight="20px"
    >
    </TextView>
    <TextView
    android:text="stock"
    android:id="@+id/stock"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#ff8400"

    ></TextView>
    </TableRow>

    <ScrollView android:id="@+id/scrollView1" android:layout_width="wrap_content" android:layout_height="150px" android:layout_above="@+id/footer" android:layout_marginLeft="10px" android:layout_marginBottom="10px">
    <TextView
    android:text="scroll"
    android:id="@+id/summary"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:layout_marginLeft="10dip"></TextView>
    </ScrollView>
    <Button android:id="@+id/button1" android:layout_height="wrap_content" android:text="Wishlist" android:layout_width="wrap_content" android:layout_alignBottom="@+id/tableRow1" android:layout_alignParentRight="true"></Button>
</RelativeLayout>

Upvotes: 0

Views: 220

Answers (2)

Dhrubo
Dhrubo

Reputation: 715

try following code in AndroidManifest.xml

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

and

suitable options for your app from following options...

<supports-screens android:resizeable=["true"| "false"]
                  android:smallScreens=["true" | "false"]
                  android:normalScreens=["true" | "false"]
                  android:largeScreens=["true" | "false"]
                  android:xlargeScreens=["true" | "false"]
                  android:anyDensity=["true" | "false"]
                  android:requiresSmallestWidthDp="integer"
                  android:compatibleWidthLimitDp="integer"
                  android:largestWidthLimitDp="integer"/>

This should solve your problem. You can also try other API sdk version instead of 8 as applicable for your app.

Upvotes: 0

Androider
Androider

Reputation: 724

You could make give that layout a weight of 1 so it takes up all space that the rest isn't using.

so for example:

your gallery takes 5% of the screen, the top takes another 10%, some other stuff takes another 5%, your layout who has weight 1 will take the other 80% of your screen.

If this isn't what you were looking for please say so :)

Upvotes: 3

Related Questions