2016-07-11 2 views
1

私は助けが必要です。私はこれを操作しようとしていますが、私はこれを行うことができないようです。私は引き出しのレイアウトにイメージを収めようとしています。 としてIヘッダー画像レイアウト(header.xml)を呼び出している:私はヘッダーイメージが正しく収まらない(DrawerLayout)

を得

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/background" 
     android:layout_marginBottom="0dp"/> 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text=" Twitter : @Someone important" 
      android:drawableLeft="@drawable/twitter" 
      android:layout_marginBottom="0dp" 
      /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text=" e-mail : [email protected]" 
     android:drawableLeft="@drawable/email" 
     /> 
</LinearLayout> 

:この(header.xmリットル)の構成について

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/drawerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <FrameLayout 
     android:id="@+id/containerView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"/> 

     <android.support.design.widget.NavigationView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     .... 
     app:headerLayout="@layout/header" <!--THIS IS THE HEADER--> 
     ... 
    </android.support.v4.widget.DrawerLayout> 

enter image description here

イメージレイアウトの高さを減らそうとしました:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="140dp" 
     android:src="@drawable/background" 
     android:layout_marginBottom="0dp"/> 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text=" Twitter : @Someone important" 
      android:drawableLeft="@drawable/twitter" 
      android:layout_marginBottom="0dp" 
      /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text=" e-mail : [email protected]" 
     android:drawableLeft="@drawable/email" 
     /> 
</LinearLayout> 

画像が途切れました。

enter image description here

+0

ヘッダーのXMLに「android:scaleType = "centerCrop"」を追加してみてください – mastrgamr

+0

あなたの活動にどのようなスタイルを使用しますか? – uguboz

+0

それはnavbarがアクションバーの後ろに立っているようです – uguboz

答えて

1

あなたのイメージあなたはこの方法でfitxyとしてスケールタイプを設定することができますので、それは左のスペースを埋めると、画像に

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="140dp" 
    android:src="@drawable/background" 
    android:scaleType="fitXY" 
    android:layout_marginBottom="0dp"/> 
をストレッチしますので、画像サイズの画面に合わせすることができません

output

+0

こんにちは、私はちょうどラインを追加しましたが、画像はまだまだオフになっています –

+0

それは画面に合っていますか? –

+0

あなたが使用している画像のサイズは –

関連する問題