2012-02-16 5 views
1

tablerow가 있고 tablerow 내부에 3 개의 요소 (ImageViews)가 있다고 가정합니다.Android 요소 고정 위치 지정

첫 번째 경우에는 3 개의 모든 항목에 가시성 값 VISIBLE이 (가) 있습니다. 요소의 가시성을 GONE으로 설정하고 있습니다. 그런 경우에 일어난 일은 다른 2 가지 항목이 한 번 놓친 곳으로 조정됩니다.

하지만 원하는 것은 고정 된 위치에있는 모든 항목이되어야합니다. 따라서 어떤 항목의 가시성을 GONE 상태로 만들면 나머지 요소도 같은 위치에있게됩니다.

누구든지이 작업을 수행 할 수 있습니까? 당신이 더 많은 유연성 항목에 원하는 경우

답변

0

사용 stretchcolumnslayout_spanlayout_column을 지정 레이아웃의 모든 ImageView에 ..

+0

자세한 내용은 ... 또는 유익한 링크를 제공 할 수 있습니다. –

0
Try this out, 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 


    <TableLayout 
     android:id="@+id/tableLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:stretchColumns="1" > 

     <TableRow 
      android:id="@+id/button" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="@drawable/topbg" > 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_column="0" 
       android:layout_span="1" 
       android:src="@drawable/ic_add" /> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_column="1" 
       android:layout_span="1" 
       android:src="@drawable/ic_add" /> 

      <ImageButton 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_column="2" 
       android:layout_span="1" 
       android:src="@drawable/ic_add" /> 
     </TableRow> 
    </TableLayout> 

</LinearLayout> 
+0

내가 무슨 뜻인지 알지 못했다고 생각합니다. 이 경우에도 똑같은 일이 일어납니다. –

0

항상 쉽게 문제를 해결할 수 있기를 바랍니다, 상대 레이아웃 이동하려고 상대 레이아웃을 사용하여. 항목을 동적으로 또는 정적으로 모두 원하는대로 할 수 있습니다.