2012-05-04 4 views
0

XML 레이아웃에 문제가 있습니다. . 아래 그림에서 보듯이, 텍스트 뷰는 어떤 android:text 필드를 포함하지 않는 체크 박스 (옆에 내가 공간을 제거 할 수있는 방법은 파란색으로 밑줄이 한확인란과 텍스트보기가 공백으로 정렬됩니다.

enter image description here

코드 :

<?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" > 

    <Button 
     android:id="@+id/bDisinstalla" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="5dp" 
     android:text="@string/disinstalla" 
     android:textColor="#FF0000" 
     android:textSize="26dp" /> 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fadeScrollbars="true" > 

     <TableLayout 
      android:id="@+id/tableLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

      <CheckBox 
       android:id="@+id/cbAbilitaServizio" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/abilita_servizio" > 
      </CheckBox> 

      <CheckBox 
       android:id="@+id/cbSpegniSchermo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/spegni_schermo" > 
      </CheckBox> 

      <CheckBox 
       android:id="@+id/cbLandscape" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/landscape" > 
      </CheckBox> 

      <Button 
       android:id="@+id/bCalibrazione" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="@string/calibrazione" /> 

문제있는 코드 : 코드의

  <!-- BELOW THERE IS THE PROBLEMATICCODE --> 
      <!-- BELOW THERE IS THE PROBLEMATICCODE --> 
      <!-- BELOW THERE IS THE PROBLEMATICCODE --> 
      <!-- BELOW THERE IS THE PROBLEMATICCODE --> 

      <TableRow 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:background="@drawable/ripetisfondo" 
       android:padding="1dp" > 

       <CheckBox 
        android:id="@+id/checkBox1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="#000000" /> 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:shadowColor="#000000" 
        android:shadowDx="1" 
        android:shadowDy="1" 
        android:shadowRadius="2" 
        android:text="@string/titolo1" 
        android:textColor="#FFFFFF" 
        android:textSize="15dp" 
        android:textStyle="bold" /> 
      </TableRow> 
      <!-- TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO --> 

나머지 :

  <!-- TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO --> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#33b5e5" 
       android:padding="1dp" > 
      </TableRow> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#555555" 
       android:padding="1dp" > 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:text="@string/impostazioni_5" 
        android:textSize="15dp" 
        android:textStyle="bold" /> 
      </TableRow> 
      <!-- TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO --> 

      <SeekBar 
       android:id="@+id/sbNumeroPassate" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" /> 

      <LinearLayout> 

       <TextView 
        android:id="@+id/tvMilliseconds" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_1a" /> 

       <TextView 
        android:id="@+id/tvCurrentWaves" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_current" /> 
      </LinearLayout> 

      <LinearLayout> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_2a" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_4a" /> 
      </LinearLayout> 

      <!-- TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO --> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#33b5e5" 
       android:padding="1dp" > 
      </TableRow> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#555555" 
       android:padding="1dp" > 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:text="@string/impostazioni_6" 
        android:textSize="15dp" 
        android:textStyle="bold" /> 
      </TableRow> 
      <!-- TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO --> 

      <SeekBar 
       android:id="@+id/sbMillisecTraPassate" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" /> 

      <LinearLayout> 

       <TextView 
        android:id="@+id/tvMilliseconds" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_1b" /> 

       <TextView 
        android:id="@+id/tvCurrentInterval" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_current" /> 
      </LinearLayout> 

      <LinearLayout> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_2b" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/impostazioni_4b" /> 
      </LinearLayout> 

      <!-- TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO --> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#33b5e5" 
       android:padding="1dp" > 
      </TableRow> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#555555" 
       android:padding="1dp" > 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:text="@string/impostazioni_7" 
        android:textSize="15dp" 
        android:textStyle="bold" /> 
      </TableRow> 
      <!-- TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO TITOLO --> 

      <LinearLayout> 

       <TextView 
        android:id="@+id/tvAccensioni" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/statistica_1" /> 

       <TextView 
        android:id="@+id/tvSpegnimenti" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/statistica_2" /> 
      </LinearLayout> 

      <LinearLayout> 

       <TextView 
        android:id="@+id/tvPotenzaUsata" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/statistica_3" /> 

       <TextView 
        android:id="@+id/tvBottoneSalvato" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:layout_marginRight="10dp" 
        android:text="@string/statistica_4" /> 
      </LinearLayout> 

      <Button 
       android:id="@+id/bSalva" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_marginTop="10dp" 
       android:text="@string/impostazioni_salva" /> 
     </TableLayout> 
    </ScrollView> 

</LinearLayout>  
+1

당신이 읽을 수있는 레이아웃의 많은 텍스트 뷰가 문제 – Javanator

+0

에있는 경우에만 단일 체크 박스와 하나의 텍스트 뷰 XML 코드를 붙여 넣을 수 있습니다와 – Javanator

+0

한다 불필요한 것을 제거하십시오 – Hoconosc

답변

0

별도의 TextView를 사용하여 String을 표시하는 대신 Checkbox의 text 속성을 사용하지 않는 이유는 무엇입니까?

  <CheckBox 
       android:id="@+id/checkBox1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#000000" 
       android:shadowColor="#000000" 
       android:shadowDx="1" 
       android:shadowDy="1" 
       android:shadowRadius="2" 
       android:text="@string/titolo1" 
       android:textColor="#FFFFFF" 
       android:textSize="15dp" 
       android:textStyle="bold" /> 
관련 문제