我正在研究Android应用程序,我想创建imageview,背景是框架,src是图像,但它们之间总是有空间 此外,我想这样做,如果他的边缘比框架更大,图像将被切割。 谢谢!
<TableLayout
android:id="@+id/layoutItems"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*"
>
<TableRow
android:id="@+id/row1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/frame_1_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp"
android:layout_marginLeft="13sp"
android:layout_marginRight="10sp"
android:contentDescription="@string/line"
android:background="@drawable/picture_gallery_frame"/>
<ImageView
android:id="@+id/frame_1_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp"
android:layout_marginLeft="10sp"
android:layout_marginRight="13sp"
android:contentDescription="@string/line"
android:background="@drawable/picture_gallery_frame"/>
</TableRow>
我有更多像这样的行,我用progamatically添加src:
File f = new File(media.get(media.size() - 1).getmMediaPath());
if (f.exists() && f != null) {
try {
Uri u = Uri.parse(f.getPath());
if (ProfileActivity.tryJpegRead(iv, f)) {
//Bitmap bitmap = BitmapUtils.getSafeDecodeBitmap(getPath(u), 512);
//iv.setImageBitmap(BitmapUtils.makeRegularScaledBitmap(bitmap, 1.0f, 1.3f));
iv.setImageURI(u);
}
} catch (Exception e) {
iv.setImageResource(R.drawable.sample);
}
} else {
iv.setImageResource(R.drawable.sample);
}