1

나는 GridView을 가지고 있으며 GridView에 이미지와 텍스트를 적용하기 위해 BaseAdapter을 사용합니다. 내 응용 프로그램을 실행할 때 'GridView'왼쪽, 오른쪽, 위쪽 및 아래쪽 여백이 한 가지 문제가 있습니다. 나는이 마진을 필요로하지 않는다.Android GridView 전체 화면

<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/strada_grid_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#d6d6d6" 
    android:gravity="center" 
    android:horizontalSpacing="1dp" 
    android:numColumns="2" 
    android:verticalSpacing="1dp" > 

</GridView> 

GridView 어댑터 xml 코드 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="120dp" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:background="#ffffff" > 

    <TextView 
     android:id="@+id/desc1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/photo1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="-27dp" 
     android:text="Hello" 
     android:textColor="#3d3b3b" 
     android:textSize="12dp" /> 

    <TextView 
     android:id="@+id/stradaID" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/desc1" 
     android:layout_alignParentBottom="true" 
     android:text="TextView" 
     android:textColor="#000000" 
     android:visibility="gone" /> 

    <ImageView 
     android:id="@+id/photo1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="38dp" /> 
</RelativeLayout> 

</RelativeLayout> 

내 문제를 해결할 수있는 방법

이것은 내 xml 소스입니까?

+0

시도

< 자원은 안드로이드를 제거하는 방법의 gridview에서 verticalSpacing. –

+0

나는 그것을 제거했지만 변경하지 않았습니다 .P.s 거기에 간격이 필요합니다. – BekaKK

+0

@PiYusH GuPtA 아니요. – BekaKK

답변

0
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/strada_grid_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#d6d6d6" 
    android:gravity="center" 
    android:horizontalSpacing="1dp" 
    android:numColumns="auto_fit" 
    android:verticalSpacing="1dp" > 

나는이 프로젝트 위치 /res/values/dimens.xml 0으로 기본 여백을 설정하고 나를 위해 작동

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" > 
1

있는 gridview 어댑터 XML 코드. horizontalSpacing 및 안드로이드 :>

<dimen name="activity_horizontal_margin">0dp</dimen> 
<dimen name="activity_vertical_margin">0dp</dimen> 

</자원>

관련 문제