2017-02-15 5 views
0

私はイメージカルーセルを使用しています。そのため、カルーセルとタイトルバーまたはアクションバーhttp://imgur.com/a/Pvonnの間にマージンがあるため、望ましくない上端に負の値を追加する必要があります。 (カルーセルのために使用される)。..不要なマージンandroid

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.mock.vivofusion.MainActivity" 

    android:background="#f58b4c"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id ="@+id/viewPagerLayout"> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewPager" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 

    </RelativeLayout> 
    ....... 

</RelativeLayout> 

swipe_layout.xml

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

    <ImageView 
     android:id = "@+id/image_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

必要であれば、私はまた、Javaクラスを提供することができます(第eコードはウェブサイトから「コピー貼り付け」されています)。

LE:どのようにスクロールをカルーセルエリアでのみアクセスできるようにすることができますか?どこでも私はイメージを動かし続ける。

+0

マイナスのマージンを持つことは、必ずしも悪いことではありません。パフォーマンスオーバーヘッドはありません。多くのSDKウィジェットには、オーバーライドしたい内部埋め込みがあるため、実際にはかなり一般的です。しかし、あなたのコードを見ると、ImageViewで設定した画像には、そのデッドスペースを引き起こす透明な背景がいくつかあります。これをテストするには、テストデバイスのデベロッパー設定に行き、レイアウト境界でビューが描画されている実際の四角形を表示できるようにします。 –

答えて

0

これは役に立ちます。android:scaleType="fitStart"

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

    <ImageView 
     android:id = "@+id/image_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scaleType="fitStart" /> 

</LinearLayout> 
+0

あなたのタグは間違っていますし、btwなぜこれは機能しますか? – gigiman

+0

@ギジマン私はイメージビューに余裕がないと思うので、それは私にパディングを追加していると思うからです。それは一度私と出会った。 –

関連する問題