0

1 또는 2 열로 나눈 이미지 집합을 표시하는보기를 작성하려고합니다. 따라서 열 수와 너비가 다를 수 있습니다.이미지 갤러리를 표시하기위한 Android보기

나는 이미 기존의 견해를 살펴 보았지만 내가 원하는 것을 성취 할 수는 없었다.

는 이미 더 나은 다음 레이아웃을 달성하기에 적합한 것이 현재 기존 안드로이드 뷰의 어떤 존재 또는 하는가 :

enter image description here

녹색 다각형 (클릭) 이미지입니다.

현재 행에 따라 다른 TableRows가 포함 된 TableLayout을 사용하고 있습니다. 그러나이 솔루션은 많은 수의 이미지에 대해 효율적으로 실행되지 않을까 걱정됩니다.

+0

, [GridLayout과. (http://developer.android.com/reference/android/support/v7/widget/GridLayout.html) –

답변

0

많은 장치에서 TableLayout으로 충분하고 규모가 적당합니다. 그러나 TableLayout은 스크롤 할 수 없다는 것을 기억하십시오. 그래서 스크롤 할 수있게하려면 (사용자가 매우 낮은 입술 화면을 가지고있는 경우를 대비하여) 표를 둘러 쌉니다 .. 기타 다음은 함께 플레이 할 수있는 골격입니다. 3 행 2 열로 구성됩니다. 첫 번째와 두 번째 행은 그림과 50/50의 비율을 가지며 마지막 행은 전체 행을 포함하는 그림에 있습니다. layout_weight로 재생하면 더 많은 공간이 포함됩니다. 행의 첫 번째 이미지에 layout_weight 2를 넣고 두 번째 이미지에 1을 놓으면 첫 번째 이미지에 더 많은 공간이 할당됩니다.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scrollbars="none" 
    android:layout_weight="1"> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/white" 
      android:layout_margin="10dp" 
      > 

      <TableRow 
       android:id="@+id/tableRow1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 

       > 

       <ImageButton 
        android:contentDescription="@string/starting_content_lessions" 
        android:id="YourId" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="YourLocation" 
        android:background="YourBackground" 
        android:layout_weight="1" /> <!-- Puting this on both items in the row makes it stretch the whole lenth --> 

       <ImageButton 
        android:contentDescription="xxx" 
        android:id="xxxx" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="xxx" 
        android:background="@drawable/custom_button" 
        android:layout_weight="1" /> 

      </TableRow> 

      <TableRow 
       android:id="@+id/tableRow2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <ImageButton 
        android:contentDescription="xxxx" 
        android:id="xxx" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="xxx" 
        android:background="@drawable/custom_button" 
        android:layout_weight="1" /> 

       <ImageButton 
        android:id="xxx" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="xxx" 
        android:contentDescription="xxx" 
        android:src="xxx" 
        android:layout_weight="1" /> 

      </TableRow> 

      <TableRow> 
       <ImageButton 
        android:id="@+id/imageButton1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="xxx" /> 
      </TableRow> 

     </TableLayout> 

</ScrollView> 
+0

감사를 시도 기본적으로 내가 지금까지 작성한 코드를 먹으 렴하세요 . 난 단지 큰 목록 (예 : 스크롤)에서 효율성에 관한 커뮤니티의 통찰력을 원했고 다른 좋은 옵션이 있다면 – dwbrito