我有一個android應用程序,我用照相手機拍照...並將圖片放在ImageView
下。我想要做的是在這張圖片的底部設置文本。在ImageView上設置文本
到現在爲止我做一樣的東西:
ImageView image;
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
image.setImageBitmap(bitmap);
u能請幫助我,告訴我我該怎麼辦未來的某些代碼將是很好的?!
編輯:XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1">
<Button
android:id="@+id/logoButton"
android:layout_height="wrap_content"
android:text="LogoButton"
android:layout_marginLeft="40dip"
android:layout_width="224dp">
</Button>
<ImageView
android:id="@+id/imageview"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</ImageView>
UPDATE:這是我用相機:
....onCreate(){
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File image=new File(Environment.getExternalStorageDirectory(),"PhotoContest.jpg");
camera.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(image));
imageUri=Uri.fromFile(image);
startActivityForResult(camera,1);
}
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode){
case 1:
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = imageUri;
getContentResolver().notifyChange(selectedImage, null);
image= (ImageView) findViewById(R.id.imageview);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
image.setImageBitmap(bitmap);
Toast.makeText(this, selectedImage.toString(),
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
.show();
Log.e("Camera", e.toString());
}
}
else
if(resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(EditPhoto.this, "Picture could not be taken.", Toast.LENGTH_SHORT).show();
}
}
}
1.I'm不知道這招用的FrameLayout把文本在我的圖片...因爲更多我想上傳照片。如果我在網站上傳照片,文字還會在那裏嗎?
2.我有相機的另一個問題......拍攝照片後......它顯示的是水平而不是全屏......>你知道我該如何解決這個問題嗎?
我有一個XML.I'm沒有得到任何空例外! – adrian
我用XML編輯了我的問題。那麼接下來呢? – adrian
@george我已經編輯我的答案要考慮到您的願望直接看到相機的預覽(而不是ImageView的) – Shlublu