음을 접견, 내 이전의 코멘트에 대해 설명하려고했던 일 : GridView
원하는 간격, 왜 그리드 항목이 알아서 만들려고하지 않는 규제 갖는 대신에? 이것에 대한 쉬운 해결책 중 하나는 GridView
의 어댑터에 사용/배치 된 레이아웃 파일의 배경으로 적절한 드로어 블을 설정하는 것입니다. 즉, 그리드 항목에 사용하는 레이아웃입니다. 당신이 언급 한 조각들.
빠른 예 : 마지막에서 마법을
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/grid_background"
android:gravity="center"
android:text="Text"
android:textColor="@android:color/white" />
을 그리고 : 그것의 내부 항목에 사용되는
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:numColumns="4" />
과 레이아웃 :
는 GridView
를 타고 배경 드로어 블 :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="5dp" android:color="@android:color/white" />
<padding android:bottom="5dp" android:left="5dp" android:right="5dp"
android:top="5dp" />
<solid android:color="@android:color/black" />
</shape>
결과는 다음 될 것입니다 :
나는 수평 및 수직 간격 매개 변수 그런데, 당신을 위해 작동하지 않는 이유를 모르겠어요.
GridView
: 나는 사람들을 사용할 때, 나는 위의 그림에서와 매우 유사한 효과를 얻을 수 있어요
이
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:horizontalSpacing="10dp"
android:numColumns="4"
android:verticalSpacing="10dp" />
항목 레이아웃 (단순히 고정 된 색의 이전 배경 자원을 교환) :
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:gravity="center"
android:text="Text"
android:textColor="@android:color/white" />
결과 :
,
희망이 있으면 도움이 될 것입니다.
그리드 항목 레이아웃의 배경으로 일부 패딩 또는 (9patch) 드로어 블을 설정할 수 없습니까? –
나는 너의 힌트를 완전히 이해하지 못한다. 무슨 뜻인지 설명해 주시겠습니까? – Henrik
@Henrik : 몇 줄에 맞지 않을 것이므로 대답으로 설명을 추가했습니다. :) 그런 다음 댓글에 다음 번에 회신 할 때'@ '(예 :'@ MH.')을 추가하십시오. 그러면 응답자에게 해당 사실을 알립니다. –