私はAndroidの開発の初心者:) 私はグリッドrecyclerView
を使用していますが、私は唯一の2 に列の数を設定しているんだと言う必要があります開始する前に私のcardView
にImageView
が1つあります。このカード(またはイメージ)を画面幅の50%にする方法がわかりません。なぜなら、数字で高さと幅を設定すると、異なる画面サイズで問題が発生するからです。ImageViewの幅は、Androidデバイスの幅の50%であることを
layout_weight
でいくつかの方法を試しましたが、これはcardView
とは動作しません。私はここでそれを行うことができますどのように
card.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="200dp"
android:layout_height="200dp"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/list_photo_double_view"
android:src="@drawable/e48"
/>
</LinearLayout>
?
おかげで、事前に
'CardView'がFrameLayout''から延びています。あなたが本当に 'CardView'を使いたいならば、' LinearLayout'をCardViewの中に入れて、次にattr layout_weightを使うことができます –