Problem when dealing with multiple screen sizes

by lou » Fri, 20 May 2011 18:04:16 GMT


Sponsored Links
 Hi !
I have some problems when dealing with different resolutions and sizes
of screen : my goal is to display an image in a square which is draw
in my background picture.
I have a main RelativeLayout which is filling the entire screen :

<RelativeLayout xmlns:android=" http://schemas.android.com/apk/res/ 
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/my_background">
    <ImageView ...
        android:id="@+id/my_imageview"
        android:src="@drawable/my_image" />
</RelativeLayout>

In my background picture, there is a square ( for example at 10px from
the left and 40px from the top of the picture ). I want to display the
ImageView my_imageview IN this square.
In my manifest :

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

I tried to set my_imageview parameters like that :

<ImageView
    ...
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="40dip"
    android:layout_marginLeft="10dip" />

But even with 3 types of drawable ( hdpi -> 1.5x, mdpi -> 1x, ldpi ->
0.75x), the imageview is not always displayed in the square.
For this  example :
- HVGA - MDPI : OK
- HVGA - HDPI : the imageview is underneath the square
- WVGA - HDPI : the imageview is a little over the square
- WVGA - HDPI : the imageview is a lot over the square
I also tried to set the layout_marginTop and the layout_marginLeft
three times ( values-small, values-normal, values-large ), but there
are still some bugs..

Is there anybody who can help me with that ?

Thanks, a lot !!
Regards

-- 



Other Threads

1. How can i implement geochat in android application?

Hi friends,

I want to implement geo chat in my android application. Can anybody
know how to implement geo chat in android.

Please give me any reference document or examples.

Thanks and Regards,

Kiran

-- 

2. display columns name at the top of list.

Hi from last 3 days I trying to display names at the top of list but
not succeed. every time column name is added for each row. What I want
is columns name is added only at the top of list. Here is my xml file

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
<LinearLayout
        android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

                <TextView
                android:text="Room Name"
                android:layout_width="85px"
                android:layout_height="wrap_content"
                android:textSize="15sp"
                android:textColor="#00FF00"
                        android:typeface="monospace"
                android:gravity="center" />


                <TextView
                android:text="Switch Name"
                android:layout_width="85px"
                android:layout_height="wrap_content"
                android:textSize="15sp"
                android:textColor="#00FF00"
                        android:typeface="monospace"
                android:gravity="center" />

          </LinearLayout>

<LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
                        android:textColor="#00FF00">
                <TextView android:id="@+id/roomName"
                android:layout_width="85px"
                android:layout_height="wrap_content"
                android:textSize="15sp"
                android:textColor="#00FF00"
                        android:typeface="monospace"
                android:gravity="center" />

                <TextView android:id="@+id/switchName"
                android:layout_width="85px"
                android:layout_height="wrap_content"
                android:textSize="15sp"
                android:textColor="#00FF00"
                        android:typeface="monospace"
                android:gravity="center" />

          </LinearLayout>

 </LinearLayout>

and The data of list is displayed from database using cursor adapter
as:

public class SwitchStatus extends ListActivity
{
        String SAMPLE_DBNAME = "NewHomeAutoDataBase";
        SQLiteDatabase sampleDB = null;
        private SimpleCursorAdapter myAdapter;
        public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        try
        {
                sampleDB =  this.openOrCreateDatabase(SAMPLE_DBNAME,
MODE_PRIVATE, null);
                System.out.println ("Inside try...");
                //Cursor c = sampleDB.rawQuery ("SELECT _id,RoomName,
group_concat(SwitchFullName,'\n')as SwitchFullName  FROM SwitchTable
GROUP BY RoomName",null);
                Cursor c = sampleDB.rawQuery ("SELECT _id,RoomName,
SwitchName from SchedulerTable ORDER BY RoomName",null);

                System.out.println (c.getCount()+"%%%%");
                startManagingCursor(c);
                String[] columns = new String[] {"RoomName", "SwitchName"};
                int[] names = new int[] {R.id.roomName, R.id.switchName};

                myAdapter = new SimpleCursorAdapter(this,
R.layout.switchstatus, c, columns,names);
                setListAdapter(myAdapter);
        }
        catch (SQLiteException se)
        {
                se.printStackTrace();
        }
    }

How to add columns name at the top of list?  Thanks

-- 

3. minta build.prop miui for HD2

4. HTC Desire HD vs Google Nexus S

5. is it possible to play flash in videoview?

6. javax.xml.xpath.XPath For android 2.0.1

7. How to store date and time in database