2013-10-26 1 views
0

저는 TableLayout (TableRow) 내부에 이미지를 센터링하는 데 문제가 있습니다. ImageView는 항상 왼쪽에 있으며 나는 그를 중심으로해야합니다. 여기ImageView를 TableRow 내부로 센터링합니다.

은 XML입니다 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#fff2d8"> 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      > 
      <ImageView 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:src="@drawable/logo" 
       android:id="@+id/imageView" 
      /> 
     </TableRow> 
    </TableLayout> 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_margin="10dp" 
     android:layout_weight="1"> 
    <TableRow 
      . 
      . 

레이아웃 이미지가있다 : screenshot

내가 어떻게 할 수 있습니까? 도와 줘서 고마워.

감사합니다, 페트르

당신 TableRow의 XML 정의에

답변

3

업데이트 android:layout_span="2"

<TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:gravity="center"> 
      <ImageView 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:src="@drawable/logo" 
       android:id="@+id/imageView" 
       android:layout_span="2"/> 
     </TableRow> 
    </TableLayout> 
+0

신난다, 그건 내 문제를 해결한다! 감사... – Jodynek

2

당신은 추가 할 수 있습니다 android:gravity="center". 이

<TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <TableRow 
      android:gravity="center_horizontal|center_vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

      <ImageView 
       android:id="@+id/imageView" 
       android:background="@drawable/ic_launcher" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:src="@drawable/logo" /> 
     </TableRow> 
    </TableLayout> 
+1

ImageView 안에이 허용 대답해야합니다. 관련없는 것들이 아니라 필요한 것을 정확히 알려줍니다. –

0

같은 레이아웃을 시도해보십시오