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. My posts are not displayed

Hi

I am new to this group. I had posted a question yesterday in this
group. It didn't appear. I thought I made a mistake; so I posted it
today and it didn't appear either. I realized now that this group has
something called moderators before it reaches the posting.

Am I missing something or did anything wrong? My question was a simple
application question and didn't have any bad language in it.

Could some please let me know if the question was rejected? If so what
is reason so that I can correct it.

Thank You and appreciate the Help!
Jacob

-- 

2. Listview and autocomplete problems!

Hi all!

Im trying to fill an autocompletetextview with data that i retrieve
from a database, so the next time we do a search that data will be in
the autocompletetextview suggestions.

The problem is that, I can view the listView associated with the
autocompletetextview (and it retrieves the data from the database
without any problem), but if i click on a single element of the
textview instead of having the string I picked on the autocomplete
textview I have an string like "sql.cur...@...".

I dont have any problems with the database as I followed the notepad
tutorial and it works well.

Thank you all and here is the code:


Java class:

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import android.app.Activity;
import android.app.ListActivity;
import android.content.ContentResolver;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Contacts;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.TextView;

import android.widget.SimpleCursorAdapter;
import android.database.Cursor;

//antes extends activity
public class RemoteIR extends ListActivity implements OnClickListener{

    static String ipquery;
    static String ipadress;
    static int ipport;

    protected static final String RESULTS="results";

    @SuppressWarnings("unchecked")
    ArrayList dataSend;
    int noSend;
    int startIndex =0;
    int count = 100;

    //antes textview
    AutoCompleteTextView adress;
    TextView port;
    TextView query;
    Button search, exit;

    private int mDataNumber = 1;
    private RemoteIrDbAdapter mDbHelper; //= null;


    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        mDbHelper = new RemoteIrDbAdapter(this);
        mDbHelper.open();

        //antes TextView
        adress = (AutoCompleteTextView)this.findViewById(R.id.adress);


        SimpleCursorAdapter notes = fillData();
        adress.setAdapter(notes);



        port = (TextView)this.findViewById(R.id.port);
        query = (TextView)this.findViewById(R.id.query);

        search = (Button)this.findViewById(R.id.search);
        search.setOnClickListener(this);

        exit = (Button)this.findViewById(R.id.exit);
        exit.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                finish();
            }
        });

    }

    @SuppressWarnings({ "unchecked" })
    public void onClick(View v) {

        ipquery = query.getText().toString();
        ipadress = adress.getText().toString();

        ipport = Integer.parseInt(port.getText().toString());

        java.util.Date tempDate = new Date();
        String date = tempDate.toString();

        mDbHelper.createQueryData(ipadress, date);
        fillData();
        mDbHelper.close();

        Log.d("RemoteIR", "creamos cliente");

        Client results;
        Thread cThread = new Thread(results = new Client(startIndex,
count));

        Log.d("RemoteIR", "arrancamos cliente");

        cThread.start();

        try {
            cThread.join();

            ArrayList finalResults = results.getResults();

            int finalNo = finalResults.size();

            Intent intent = new Intent();

            intent.setClass(RemoteIR.this, DisplayResult.class);

            dataSend = finalResults;
            noSend = finalNo;

            int startIndex = 0;
            int endIndex = 10; //ANTES 9

            ActivitySwitchInfo asi = new ActivitySwitchInfo(dataSend,
noSend, startIndex, endIndex);

            intent.putExtra(RESULTS, asi);

            startActivity(intent);

            finish();

         }
         catch (InterruptedException e) {
            Log.e("RemoteIR", "Join interrupted", e);
         }

    }


     private void createData() {
            String queryDataName = "QueryData " + mDataNumber++;

            mDbHelper.createQueryData(queryDataName,"");
            fillData();
        }


    private SimpleCursorAdapter fillData() {
        Cursor c = mDbHelper.fetchAllQueryData();
        startManagingCursor(c);
        String[] from = new String[] { RemoteIrDbAdapter.KEY_QUERY};
        int[] to = new int[] { R.id.row1 };

        SimpleCursorAdapter notes =
            new SimpleCursorAdapter(this, R.layout.query_row, c, from,
to);


        return notes;
        //setListAdapter(notes);
    }


}


XML files:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:id="@+id/widget29"
android:layout_width="250px"
android:layout_height="180px"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"

<ListView android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@android:id/list"></ListView>

<AutoCompleteTextView
android:id="@+id/adress"
android:layout_width="fill_parent"
android:layout_height="50px"
android:text="IP"
android:textSize="18sp"

</AutoCompleteTextView>
<EditText
android:id="@+id/port"
android:layout_width="fill_parent"
android:layout_height="50px"
android:text="Port"
android:textSize="18sp"
</EditText>
<EditText
android:id="@+id/query"
android:layout_width="fill_parent"
android:layout_height="50px"
android:text="Query"
android:textSize="18sp"
</EditText>
</LinearLayout>
<Button
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
</Button>
<Button
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exit"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
</Button>
</RelativeLayout>


And:

<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/row1"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

Ty!

-- 

3. How to implement answer function programmetically?

4. Two processes are created on first running of my application?

5. What is the best way to schedule an event that will wake up the phone if it goes into sleep mode?

6. can't compile opencore

7. colud i join Android Developers group?