2010-11-22 13 views
0

私はxmlファイルのLinearLayoutの中に中心を置くImageViewを持っています。私は写真をスナップし、顔を検出し、それをImageViewに表示します。問題は、常に私の携帯電話の左側に表示されている(私は、アプリケーションが永久にportraitモードに設定されている)... widthfill_parentにして、heightを修正したいどのように表示されるかについては何もしていない。私はImageViewbitmapを設定する場所私の人生のために私の画像が正しく表示されない理由を把握することができません

<ImageButton 
    android:id="@+id/YesButtonTitle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/yesface" 
    android:layout_gravity="top|center" /> 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/image_view" 
    android:gravity="center" 
    android:layout_weight="1.0"/> 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/message" 
    android:gravity="center_horizontal" 
    android:padding="10dip"/> 

<Button 
    android:layout_gravity="center_horizontal" 
    android:layout_width="fill_parent" 
    android:textStyle="bold" 
    android:id="@+id/action_button" 
    android:selectAllOnFocus="false" 
    android:layout_height="100dip" 
    android:text="Click here to crop detected face"/> 

ここにある:

((Button) findViewById(R.id.action_button)) 
     .setOnClickListener(btnClick); 
mTheMessage.setText(R.string.faceMessage); 
mThePicture = (ImageView) findViewById(R.id.image_view); 
mThePicture.setImageBitmap(bitmap565); 

ここ

は私xmlコードがありますその後、圧縮された

Bitmap bitmap565 = Bitmap.createBitmap(width, height, Config.RGB_565); 

:は、以下のように定義されて

try { 
    FileOutputStream fos = new FileOutputStream(filepath); 
    bitmap565.compress(CompressFormat.JPEG, 90, fos); 
    fos.flush(); 
    fos.close(); 
} catch (FileNotFoundException e) { 
    e.printStackTrace(); 
} catch (IOException e) { 
    e.printStackTrace(); 
} 

私はImageViewbmpを表示する前に。誰でも何故行動しないのか、そしてImageViewは正しく考えられますか?

答えて

0

これは私のために働いた、多分それはあなたのために働くでしょう。

<ImageView 
    android:id="@+id/image_id" 
    android:padding="2dip" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:scaleType="centerInside" 
    android:layout_weight="1"/> 

なぜあなたのXMLは機能しません。私は見て、おそらくアンドロイド:画像の場合は何もしないように見える重力を除いて、すべてがうまくいくように見えます。

+0

の効果が得られます...私はXMLに私がやりたいことができるように思われますファイル、それはまだ同じ方法を表示する - 私は私のクラスで何か間違っていることができますか? – Sapp

+0

私は排除のプロセスを行います。 XMLの他のすべてを取り出し、それがどのように見えるかを見てください。必要に応じて表示されるまで作業してから、他のウィジェットを追加してください。 – Eliseo

1

セットlayout_width =「wrap_content」fill_parentない、そして、唯一のあなたはまだ同じ結果親のレイアウト重力

<ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/image_view" 
     android:gravity="center" 
     android:layout_weight="1.0"/> 
関連する問題