2016-04-12 18 views
0

Edit, it's on top, now it's zoomed inイメージ上に完全ではありません、私は

それを配置したい場所、それが可能なら、私は間にスペースを残さない、完全に上に、画像を、賢明な幅、それは画面全体を埋めるためにしたいと思います上部と画像。これは私のために働いていません。

これは私が持っているmain.xmlコードです。それは完全に間違っている可能性があります。その場合は教えてください。

This is how it looks in the emulator, I want it to fill the entire top side from left to right, completely on the top.

任意の助けをいただければ幸い、私はこれにかなり新しいので、私は間違っている私に教えて怖がってはいけない:)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.rodekruis.MainActivity"> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true"> 
    <ImageView 
     android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
     android:src="@drawable/rkz_logo" 
     /> 

    </RelativeLayout> 

    <Button 
     android:id="@+id/button2" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/button9" 
     android:layout_alignLeft="@+id/button10" 
     android:layout_marginBottom="30dp" 
     android:layout_gravity="top" 
     android:clickable="true" 
     android:text="Nieuws" /> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_marginBottom="20dp" 
     android:orientation="horizontal"> 

     <Button 
      android:id="@+id/button10" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignTop="@+id/button8" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text=" Afspraak maken" /> 


     <Button 
      android:id="@+id/button8" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text=" Bezoek tijden" /> 

     <Button 
      android:id="@+id/button9" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_weight="1" 
      android:text="Contact" /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="20dp" 
     android:orientation="horizontal"> 


     <Button 
      android:id="@+id/button3" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text=" Geef je mening!" /> 


     <Button 
      android:id="@+id/button4" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text=" Route begeleiding" /> 

     <Button 
      android:id="@+id/button1" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignLeft="@+id/button5" 
      android:layout_below="@+id/button8" 
      android:layout_marginLeft="5dp" 
      android:layout_weight="1" 
      android:text="Specia-listen" /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_marginTop="10dp" 
     android:orientation="horizontal"> 

     <Button 
      android:id="@+id/button5" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text="BWC" /> 


     <Button 
      android:id="@+id/button6" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:layout_weight="1" 
      android:text="Agenda" /> 


     <Button 
      android:id="@+id/button7" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:layout_weight="1" 
      android:text="Praktische 
informatie" /> 
    </LinearLayout> 

</LinearLayout> 
+0

ImageViewでandroid:layout_alignParentTop = "true"を削除し、アンドロイドをすべて削除します。******* = "@ dimen/activity_horizo​​ntal_margin" –

答えて

0

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:scaleType="centerCrop" 
    android:src="@drawable/rkz_logo" 
    /> 
+0

これは、画面全体が左から右になりますが、画像を完全にズームします。 –

+0

あなたはスクリーンショットを共有してください。私はそれがどのように見えることを確認することができるように? –

+0

が投稿に追加されました。上部には画像へのリンクがあります –

0

ちょうどあなたのパディングを削除します。私はそれが

android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
+0

これらの4行を完全に削除しました。とにかくありがとう:) –

+0

あなたの重力アンドロイドも残して申し訳ありません申し訳ありません:gravity = "center" – abdoulayeYATERA

0

android:gravity="center" 
android:paddingTop="@dimen/activity_vertical_margin" 

はこれを試してみてくださいレイアウトルートに2行を削除し、これを試すのに役立ちます願っています。 ImageViewの親に

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
tools:context=".MainActivity"> 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@mipmap/ic_launcher" /> 

<Button 
    android:id="@+id/button2" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    android:layout_gravity="top" 
    android:layout_marginBottom="30dp" 
    android:clickable="true" 
    android:text="Nieuws" /> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_marginBottom="20dp" 
    android:orientation="horizontal"> 

    <Button 
     android:id="@+id/button10" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:text=" Afspraak maken" /> 


    <Button 
     android:id="@+id/button8" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:text=" Bezoek tijden" /> 

    <Button 
     android:id="@+id/button9" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_weight="1" 
     android:text="Contact" /> 

</LinearLayout> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_marginBottom="20dp" 
    android:layout_marginTop="10dp" 
    android:orientation="horizontal"> 


    <Button 
     android:id="@+id/button3" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:text=" Geef je mening!" /> 


    <Button 
     android:id="@+id/button4" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:text=" Route begeleiding" /> 

    <Button 
     android:id="@+id/button1" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_alignLeft="@+id/button5" 
     android:layout_below="@+id/button8" 
     android:layout_marginLeft="5dp" 
     android:layout_weight="1" 
     android:text="Specia-listen" /> 

</LinearLayout> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_marginTop="10dp" 
    android:orientation="horizontal"> 

    <Button 
     android:id="@+id/button5" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:text="BWC" /> 


    <Button 
     android:id="@+id/button6" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_weight="1" 
     android:text="Agenda" /> 


    <Button 
     android:id="@+id/button7" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="5dp" 
     android:layout_weight="1" 
     android:text="Praktische informatie" /> 
</LinearLayout> 

+0

ありがとう!これで一番上のスペースがなくなり、今度は画像が上になります。これで、幅全体を塗りつぶすだけです。それが正しいイメージではないかもしれないので、イメージを台無しにすることなくそれが可能かどうかはわかりません。 –

0

android:layout_alignParentTop="true"その親(ルートビュー)がRelativeLayoutではないので無視されます。ルートビューをRelativeLayoutに変更して、パディング(少なくとも1つ上のもの)を削除してみてください。

関連する問題