img.setTranslationX fonctionne sur mon émulateur mais pas sur mon smartphone
Bonjour,
Je viens commencer le développement d'une petite application sous android, elle fonctionne très bien sur l’émulateur mais une fois installée sur mon smartphone j'ai un message "Fermeture soudaine de l'application .... Merci de réessayer".
Si je mets la commande img.setTranslationX(x) en commentaire l'application se lance, mais évidement mon image ne se place pas ou je veux.
Au début je croyais que c’était a cause du LinearLayout j'ai essayé avec AbsoluteLayout, c'est pareil. Bref j'ai tout testé.
Voici le code d'un simple test qui fonctionne sur mon émulateur mais pas sur mon smartphone.
Merci de votre aide.
Code:
1 2 3 4 5 6 7 8 9 10 11
| public class TestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img= (ImageView)findViewById(R.id.crenau_j1);
img.setTranslationX(50);
}
} |
avec main.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/crenau_j1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/crenau_1" android:visibility="visible"/>
</LinearLayout> |