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. this site in not available android plug in for Eclipse

If you're trying to manually install the eclipse plugin (ADT Plugin)
then you can download it at

http://dev.android.com/sdk/adt_download.html

Then follow these steps:

1. Start Eclipse, then select Help > Software Updates....
2. In the dialog that appears, click the Available Software tab.
3. a) In Eclipse 3.3, click New Archive Site....
    b) In Eclipse 3.4, click Add Site..., then Archive...
4. Browse and select the downloaded the zip file.
5. Back in the Available Software view, you should see the plugin.
Select the checkbox next to Developer Tools and click Install...
6. On the subsequent Install window, "Android Developer Tools", and
"Android Editors" should both be checked. The Android Editors feature
is optional, but recommended. If you choose to install it, you need
the WST plugin mentioned earlier in this page. Click Next.
7. Accept the license agreement and click Finish.
8. Restart Eclipse.


Hope this helps.



--
Malformed message exception

--~--~---------~--~----~------------~-------~--~----~

2. Help with SimpleCursorAdaptor

Hi,

I am having some problems trying to extend the SimpleCursorAdapter,
the problem I am trying to solve is simple. I have the 'id' of an SMS
message and I want to associate this with the Name of the person who
sent it (if in the contact-book).

Basically I want to get the current cursor position , check if the
name exists and if so associate it with and @id tag in my layout.

The activity calls the extended cursor as follows:
===================================
                String[] columns = new String[] { SMSConstants.ADDRESS,
SMSConstants.BODY};
                int[] names = new int[] { R.id.subject, R.id.message  };
                Cursor c = getSMSCursor();
                startManagingCursor(c);
                SMSCursorAdaptor myAdapter = new SMSCursorAdaptor(this,
R.layout.table, c, columns, names);

                setListAdapter(myAdapter);


The extended Cursor Class is defined as:
===================================


public class SMSCursorAdaptor extends SimpleCursorAdapter {


        private Cursor c;
        private Context context;
        private int layout;


        public SMSCursorAdaptor(Context context, int layout, Cursor c, String
[] from, int[] to) {


                super(context, layout, c, from, to);
                this.c = c;
                this.context = context;
                this.layout = layout;

        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent)
{

                /* Get the current Cursor */
                Cursor cursor = getCursor();

                /* Know the context */
                ContentResolver cr = context.getContentResolver();

                LayoutInflater inflate = LayoutInflater.from(context);
        View v = inflate.inflate(layout, parent);

        /* get the text view */
                TextView textView = (TextView) v.findViewById(R.id.row_entry);

                /* Now get the id number of the person */
                int id = this.c.getColumnIndex("person");

                /* Connection string to the DB */
                Uri uri = ContentUris.withAppendedId(People.CONTENT_URI,
this.c.getLong(id));
                /* Make the query */
                Cursor person_cursor = cr.query(uri, null, null, null, null);

                int idx = person_cursor.getColumnIndex(People.DISPLAY_NAME);
                //String nameValue = person_cursor.getString(idx);
                v.setId(idx);
                return v;
        }

}

Basically I am not sure how to set-up the textView so that it gets the
correct DISPLAY_NAME from the db and outputs it to the @id tag ...

No matter what I have tried I get an IndexOutOfBoundsException

04-18 13:06:19.675: ERROR/AndroidRuntime(252):
android.database.CursorIndexOutOfBoundsException: Index -1 requested,
with a size of 1
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.database.AbstractCursor.checkPosition(AbstractCursor.java:559)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.database.AbstractWindowedCursor.checkPosition
(AbstractWindowedCursor.java:172)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.database.AbstractWindowedCursor.getString
(AbstractWindowedCursor.java:41)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.database.CursorWrapper.getString(CursorWrapper.java:135)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
com.zoomsms.android.util.SMSCursorAdaptor.bindView
(SMSCursorAdaptor.java:51)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.CursorAdapter.getView(CursorAdapter.java:186)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.AbsListView.obtainView(AbsListView.java:1075)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.ListView.measureHeightOfChildren(ListView.java:1107)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.ListView.onMeasure(ListView.java:1051)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.View.measure(View.java:6744)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:
890)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.LinearLayout.measureVertical(LinearLayout.java:347)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.LinearLayout.onMeasure(LinearLayout.java:275)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.View.measure(View.java:6744)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.FrameLayout.onMeasure(FrameLayout.java:208)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.View.measure(View.java:6744)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.LinearLayout.measureVertical(LinearLayout.java:461)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.LinearLayout.onMeasure(LinearLayout.java:275)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.View.measure(View.java:6744)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.widget.FrameLayout.onMeasure(FrameLayout.java:208)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.View.measure(View.java:6744)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.ViewRoot.performTraversals(ViewRoot.java:620)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1103)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.os.Handler.dispatchMessage(Handler.java:88)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.os.Looper.loop(Looper.java:123)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
android.app.ActivityThread.main(ActivityThread.java:3739)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
java.lang.reflect.Method.invokeNative(Native Method)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
java.lang.reflect.Method.invoke(Method.java:515)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:739)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
04-18 13:06:19.675: ERROR/AndroidRuntime(252):     at
dalvik.system.NativeStart.main(Native Method)


Help appreciated !!!

-Avron


--~--~---------~--~----~------------~-------~--~----~

3. Android SDK 1.5 Linux Permission Troubl

4. how to make ImageView to zoom and scroll

5. process closing unexeptedly in emulator

6. This errors on Second Acvivity

7. Help in installing ADT for eclipse