Screen density & screen layout size

by Chopcsu » Mon, 14 Dec 2009 08:34:51 GMT


Sponsored Links
 Hi,

I am having problems getting Android to use the correct resources.

I am trying to have it pick the correct resources across all densitys
and screen layouts & orientations.

So I have created the directory structure as follows


drawable
drawable-large
drawable-large-land
drawable-large-port
drawable-normal-hdpi
drawable-normal-mdpi
drawable-normal-ldpi
drawable-normal-land-hdpi
drawable-normal-land-mdpi
drawable-normal-land-ldpi
drawable-normal-port-hdpi
drawable-normal-port-mdpi
drawable-normal-port-ldpi
drawable-small
drawable-small-land
drawable-small-port

Since large screen layouts are always hi res screens (480x800,480x848)
and small screen layouts are always lowres(240x320,240x400 etc) i did
not include density descriptions in the directory naming.
And likewise since normal can be low,medium of high resolution
screens, I have included all the different density markers.

I am not sure if android likes me naming the directories like this
since when I load up the normal 320x480 screen,
It is selecting Hi-res resources and down-scaling them. I can see
nowhere in documentation that says this is what it will do so im am
quite confussed as this is what it seems like it is doing.

I am using

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

Yet I am positive it is resizing the resources automatically for me.
Testing with 2.0 emulators.

When using the WVGA emulators, it uses the hdpi resources unscaled,
when using the 320x480 emulator, it is using the hdpi resources down-
scaled.

Any ideas on where I am going wrong?


--



Other Threads

1. How to determine where a CheckedTextView is 'clicked'

Hello,

I want to know if a user has selected the text portion or the check
box graphic portion of a CheckedTextView. I want different behaviour
depending on where they select. If they click on the text then I want
to edit the underlying object and if they select the check box then I
want to close off the object.

Currently I am using but this listener is called no matter where the
CheckedTextView is selected...
listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    public void onItemClick(AdapterView<?> arg0, View arg1, int
position, long id) {
...
}});

Thanks,
JP

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

2. Subclassed ImageView does not draw in Gallery View

I am subclassing the ImageView class and adding to the Gallery View.
But, nothing seems to get drawn in the expected location; though I can
fling through the Gallery list. I added an image from a resource, and
it shows up correctly in the Gallery.

Any idea on why this may be happening?

Here is the code I am using:
public class CustomCanvas extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Gallery g = (Gallery) findViewById(R.id.gallery);
        g.setAdapter(new ImageAdapter(this));
    }

    private class CustomImageView extends ImageView {

        public CustomImageView(Context context) {
                this(context, null);
        }

        public CustomImageView(Context context, AttributeSet attrs) {
                this(context, attrs, 0);
        }

        public CustomImageView(Context context, AttributeSet attrs, int
defStyle) {
                super(context, attrs, defStyle);
        }

        protected void onDraw(Canvas canvas)
        {
            canvas.drawColor(Color.BLUE);
        }

    }

    private class ImageAdapter extends BaseAdapter{

        public ImageAdapter(Context c) {
            mContext = c;
        }

                public int getCount() {
                        return 2;
                }

                public Object getItem(int position) {
                        return position;
                }

                public long getItemId(int position) {
                        return position;
                }

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

                if (position == 1)
                {
                    ImageView i = new ImageView(mContext);
                i.setImageResource(R.drawable.icon);
                return i;
                }
                else
                {
                        CustomImageView w = new CustomImageView(mContext);
                        w.invalidate();
                        return w;
                }
        }

                 private Context mContext;

    }

}

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

3. get information from web service

4. Emulator boot without the GUI interface, just show the "ADDROID" screen saver

5. MVC model state change requires creating an Intent?

6. Spinner development

7. Change the location of the tab in a TabLayout