2017-07-31 3 views
0

私はこのrecyclerviewを持っていて、背景はimageviewsで作られています。私はこれら2つの状況を肖像画と風景の中に持っています。ホワイトスペースを新しい画像ビューや同じ色のもので埋めるにはどうしたらいいですか?2つのイメージビューで横向きの幅を塗りつぶします

portraitlandscape

そして、これは私のxmlです:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal"> 

<ImageView 
    android:id="@+id/home_imageview_superbackground" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentStart="true" /> 

<ImageView 
    android:id="@+id/home_imageview_background" 
    android:contentDescription="Background image" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:adjustViewBounds="true" 
    android:layout_alignParentEnd="true" /> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerVertical="true"> 

    <TextView 
     android:id="@+id/content" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:fontFamily="casual" 
     android:paddingBottom="10dp" 
     android:paddingStart="5dp" 
     android:paddingTop="10dp" 
     android:textAppearance="?attr/textAppearanceListItem" 
     android:textColor="@android:color/white" 
     android:textSize="40sp" /> 
</RelativeLayout> 

は、いくつかの方法を試してみましたが、私はこの仕事をすることができませんよ。 @ + id/home_imageview_superbackgroundこれは、風景の中のそのスペースを埋めるために各背景画像ビューの左に置いておきたい画像ビューです。お手伝いありがとう。

答えて

0
<ImageView 
android:layout_width="match_parent" 
.... /> 

また、あなたはscaleType属性

+0

この描画可能ファイルを作成します。どのようにあなたのコードがどうあるべき

助けてください:) – Weizen

+0

申し訳ありません。ランドスケープバリエーションレイアウトを作成します。 –

1

を使用することができ、この1

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <ImageView 
     android:id="@+id/home_imageview_superbackground" 
     android:layout_width="match_parent" 
     android:src="@mipmap/ic_launcher" 
     android:scaleType="fitXY" 
     android:layout_height="wrap_content" /> 

    <ImageView 
     android:id="@+id/home_imageview_background" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:src="@mipmap/ic_launcher" 
     android:scaleType="fitXY" 
     android:contentDescription="Background image" /> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true"> 

     <TextView 
      android:id="@+id/content" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:fontFamily="casual" 
      android:paddingBottom="10dp" 
      android:paddingTop="10dp" 
      android:textAppearance="?attr/textAppearanceListItem" 
      android:textColor="@android:color/white" 
      android:textSize="40sp" /> 
    </RelativeLayout> 
</RelativeLayout> 

を試してみてくださいまた、アンドロイドを使用することができます。scaleType = "centerCrop"。これはyou..Ifを助ける

希望はまだあなたがmatch_parent代わりを使用する必要があり、fill_parentは回前に廃止されました...

0

ファーストをお知らせください問題に直面しています。次に、ImagesViewを使用しているときにscaleTypeを使用して、画像が画面上でどのように表示されるかを定義する必要があります。あなたの場合は、scaleType = "fitXY"を使って問題を解決してください。私は申し訳ありませんメイトだけど、あなたもしようとしていない

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<ImageView 
    android:id="@+id/home_imageview_superbackground" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scaleType="fitXY" 
    android:layout_alignParentStart="true" /> 

<ImageView 
    android:id="@+id/home_imageview_background" 
    android:contentDescription="Background image" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:scaleType="fitXY" 
    android:adjustViewBounds="true" 
    android:layout_alignParentEnd="true" /> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerVertical="true"> 

    <TextView 
     android:id="@+id/content" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:fontFamily="casual" 
     android:paddingBottom="10dp" 
     android:paddingStart="5dp" 
     android:paddingTop="10dp" 
     android:textAppearance="?attr/textAppearanceListItem" 
     android:textColor="@android:color/white" 
     android:textSize="40sp" /> 
</RelativeLayout> 
+0

ありがとうございます、私はmatch_parentでfill_parentをすべて修正します – Weizen

+0

scaleTypeはあなたの問題を解決しましたか? –

0

<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <ImageView 
     android:id="@+id/your_image" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:src="@mipmap/ic_launcher" 
     android:scaleType="fitEnd" 
     android:layout_alignParentStart="true" 
     android:background="@drawable/green_gradiant" 
     android:padding="10dp" /> 

    <TextView 
     android:id="@+id/content" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:fontFamily="casual" 
     android:paddingBottom="10dp" 
     android:paddingStart="5dp" 
     android:paddingTop="10dp" 
     android:text="Hello Three" 
     android:textAppearance="?attr/textAppearanceListItem" 
     android:textColor="@android:color/white" 
     android:textSize="40sp" /> 
</FrameLayout> 

このコードを試してみて

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <shape android:shape="rectangle"> 
     <gradient android:angle="0" 
      android:startColor="#64FFDA" 
      android:centerColor="#4464FFDA" 
      android:endColor="#0064FFDA"/> 
    </shape> 
</item> 
</selector> 
関連する問題