画像を表示するためにアンドロイドでギャラリーを使用しています。私の質問は、ギャラリー内の imageViews の余白をどのように設定すれば、それらが互いに隣り合っているのではなく、それらの間にいくらかのスペースができるようにすることです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Gallery
android:id="@+id/glr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<ImageView
android:id="@+id/imageView1"
android:layout_marginTop="100dp"
android:layout_width="250dp"
android:layout_gravity="center_horizontal"
android:layout_height="250dp" />
</LinearLayout>
そして、これは私がギャラリーにimageViewを設定する方法です:
public View getView(int index, View view, ViewGroup viewGroup)
{
ImageView i = new ImageView(mContext);
i.setImageBitmap(photos[index]);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(50, 50, 50, 50);
i.setLayoutParams(params);
return i;
}