概要: 私は Android 開発の初心者であり、カードに画像 (.jpg) を表示するために Gabriele Mariotti の優れた cardslib を使用しています。余白なしでカード全体を覆う画像が必要です。代わりに、画像のすべての側面に不要な 12 dp のマージンが表示されます。いろいろ試してみましたが、この余白をなくすことはできませんでした(余白を0dpに設定)。
詳細: カードに .jpg を表示しています。カードには .jpg しかありません (つまり、ヘッダーもサムネイルもありません)。問題は、カードのすべての面に余分な空白が表示されることです。.jpg とカードの相対的な縦横比に応じて、上/下または左/右の端により多くの空白がありますが、最小の空白は正確に 12 dp です。
ドキュメント、特にCARD ドキュメントを見ると、layout_marginTop や layout_marginBottom などを設定する必要があるようです。これらのさまざまな順列をいくつか試しましたが、12 dp のマージンを削除できませんでした。現在、私のレイアウトは次のようになっています。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp" >
<it.gmariotti.cardslib.library.view.CardViewNative
android:id="@+id/carddemo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp" />
</LinearLayout>
と
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="238dp">
<ImageView
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"/>
</LinearLayout>
(上記の設定の多くは冗長で、不必要で、ばかげていることに気づきました。正しい設定を見つけた後、不要なものを削除するつもりでした。)
stackoverflow の「cardslib」タグで「margin」(1 ヒット)、「marginTop」(0 ヒット)、「padding」(1 ヒット)、「layout」(25 ヒット) を検索しましたが、いずれにも解決策が見つかりませんでした。それらの答え。