私はImage GalleryのようなアプリをWebから取得した画像で開発しています。すべての画像は同じ幅の200px
で、高さは280-300px
です。私はRecyclerView
とAdapter.ViewHolder
とGridLayoutManager
をスパン= 2のカウントで使用します。画像はPicasso
ライブラリでロードされます。私のデバイス5" 720x1280
でイメージギャラリーアプリをすべての異なる画面サイズで同じように見えるようにするにはどうすればよいですか?
item_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tile_picture"
android:layout_width="match_parent"
android:layout_height="260dp"
android:layout_margin="1dp"
android:scaleType="centerCrop"/>
それが正常に見えています。 5.5" 1080x1920
には、画像間に余白があります。 5.5" 1080x1920
で、画像間に余白があります。 古い3.7" 480x800
には、半画面サイズより1つのスパン、幅のビットがあります。 android:layout_height="260dp"
がハードコードされているので、私はお勧めします。 異なるデバイスで同じ外観を得るにはどうすればいいですか?
ありがとうございました。代わりに、私はちょうど '@Overrideを試しました。 public TopViewHolder onCreateViewHolder(ViewGroup parent、int viewType){ View view = LayoutInflater.from(mContext).inflate(R.layout.main_tile_item、parent、false); int width =(parent.getMeasuredWidth()/ 2) - 4; int height =(int)(width * 1.5); view.setMinimumHeight(height); 新しいTopViewHolder(ビュー)を返します。 } 'それはうまくいくようです! –