2015-01-20 1 views
0

안녕 얘들 아, 나는 안드로이드에 새로운이야. 내 응용 프로그램을 구조화하기 위해 1 열 4 행이있는 GridLayout을 사용하고 싶습니다.어떻게 내 gridlayout xml의 각 행의 높이를 설정합니까

<GridLayout 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="horizontal" 
    android:columnCount="1" 
    android:rowCount="4" 
    tools:context=".MainActivity"> 

</GridLayout> 

유일한 차이는 내 행이 다른 높이를 갖게하려는 것입니다. xml의 ​​각 행에 대해이를 지정하는 방법이 있습니까?

답변

0

예! 당신이 당신의 grid_item.xml을 만든 후에 http://androidexample.com/Custom_Grid_Layout_-_Android_Example/index.php?view=article_discription&aid=76&aaid=100

, 당신이 편집 할 수 있습니다 당신은이 튜토리얼을 살펴해야합니다

당신은 당신이 각 행의 크기를 지정할 수있는 CustomGridAdapter을 작성해야 java 응용 프로그램에서 OnCreate()의 각 행 크기. 예를 들어

:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:padding="5dp" > 

<ImageView 
    android:id="@+id/grid_item_image" 
    android:layout_width="50px" 
    android:layout_height="50px" 
    android:layout_marginRight="10px" 
    android:src="@drawable/android_logo" > 

</ImageView> 

다음 CustomGridAdapter에 각 이미지 뷰의 너비/높이의있는 LinearLayout의 "wrap_content"을 설정할 수 있습니다 은 아래 grid_item.xml 설정 행이 ImageView의 크기를 처리한다는 것을 의미합니다.

건배!

관련 문제