2014-11-11 2 views
0

나는 다음 템플릿을 가지고 :ImageView를 맨 아래로 설정하는 방법은 무엇입니까?

<?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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:background="@drawable/fight" 
    tools:context="ru.net.babobka.FightActivity" > 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="150dp" 
     android:layout_height="180dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:src="@drawable/ken1" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="150dp" 
     android:layout_height="190dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:src="@drawable/ryu1" /> 

</RelativeLayout> 

결과는 다음과 같습니다

enter image description here

당신은 이미지와 아래쪽 테두리 사이에 공백이 볼 수 있듯이. 어떻게 피하는거야?

답변

1

상대 레이아웃에는 패딩이 있습니다. 즉, 모든 콘텐츠를 내부로 밀어 넣을 것입니다. 패딩을 제거하십시오.

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

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:gravity="bottom|left" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ken1" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:gravity="bottom|right"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ryu1" /> 
</LinearLayout> 

1

은 다음과 같이 레이아웃을 수정

<?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:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:background="@drawable/fight" 
android:layout_alignParentBottom="true" 
tools:context="ru.net.babobka.FightActivity" > 

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="150dp" 
    android:layout_height="180dp" 
    android:layout_alignParentLeft="true" 
    android:src="@drawable/ken1" /> 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="150dp" 
    android:layout_height="190dp" 
    android:layout_alignParentRight="true" 
    android:src="@drawable/ryu1" /> 

</RelativeLayout> 
관련 문제