2014-09-18 6 views
0

ListView이 있습니다. 각 행에는 LinearLayout 안에 항목이 있습니다. LinearLayout에는 layout_margin이 10dp입니다. 내가 그것을 누르면 셀렉터 배경을 배치했습니다. 그러나 문제는 10dp의 여백 경계에서 주황색 배경색이 나타나고 LinearLayout 검은 색 배경이 올바르게 표시된다는 것입니다.LinearLayout 누를 때 테두리 색상이 표시되지 않습니다.

여백에서 주황색 배경을 어떻게 제거 할 수 있습니까?

선택기

<item android:state_pressed="true"> 
    <shape> 
     <gradient android:angle="90" android:startColor="@color/negro" android:endColor="@color/negro" /> 
    </shape> 
</item> 

    <item android:state_enabled="true"> 
    <shape> 
     <gradient android:angle="90" android:startColor="@color/grisOscuro" android:endColor="@color/grisOscuro" /> 
    </shape> 
</item> 

XML

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:background="@color/black" 
    android:orientation="horizontal"> 

<LinearLayout 
    android:baselineAligned="false" 
    android:id="@+id/fondoListviewRow" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/grey" 
    android:orientation="horizontal"> 

... 

</LinearLayout> 

,

코드

holderName.fondo.setBackgroundResource (R.drawable.listview_negro);

+0

당신이 목록 뒤에 어딘가 오렌지 배경이 있습니까 나에게 준다? –

+0

아니요, LinearLayout을 – user4152

+0

으로 누르면 주황색 배경이 만들어지고 주황색 부분이 여백의 일부에 나타 납니까? 또는 완전한 10dp가 주황색입니까? 스크린 샷이나 무언가를 넣을 수 있다면 좋을 것입니다. –

답변

0

나는 배경 뒤에 오렌지색 배경이 있다고 생각합니다.

패딩

경계와 실제보기의 내용 사이의 경계 내부의 공간입니다. 패딩은 내용 주위로 완전히 이동합니다. 위쪽, 아래쪽, 오른쪽 및 왼쪽 (독립적 일 수 있음)에 패딩이 있습니다.

여백

국경이 뷰 옆에 다른 구성 요소 사이의 경계 외부의 공간이다. 패딩과 마찬가지로 여백은 내용 주위로 완전히 이동합니다. 위쪽, 아래쪽, 오른쪽 및 왼쪽에 여백이 있습니다.

android : padding = "10dp"insted를 사용해보세요.그것은 당신에게 문제를 해결해야합니다.

편집 :

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="200dp" 
    android:background="#FF0000" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_margin="10dp" 
     android:background="#00FF00" > 
    </LinearLayout> 
</LinearLayout> 

위의 코드

enter image description here

+0

LinearLayout에는 여백을 원한다면 위쪽, 아래쪽, 왼쪽 및 오른쪽 여백을 10dp – user4152

+0

갖고 싶습니다. 그러나 그것은 투명 할 것이고, 배경색에있을 것 인 어떤 색이라도 마진에 반영 될 것이다. 귀하의 경우에는 주황색 배경이 뒤에있는 것처럼 보이므로 여백은 주황색입니다. –

+0

해결책이 없습니까? – user4152

0

문제에 대한 설명을 토대로, 응용 프로그램 매니페스트에서 선택한 응용 프로그램의 테마를 전환하거나 응용 프로그램 » android : theme하에 변경해야한다고 생각합니다. 스타일은 res » 값 아래에 있습니다. 또는 관심있는 요소와 관련된 스타일을 다시 정의해야합니다.

이 깊숙이 파고 전에에 테마를 전환 :

android:theme="@android:style/Theme.Black" 

또는

android:theme="@android:style/Theme.Light" 

또는

android:theme="@android:style/Theme.NoTitleBar" 

... 어떻게되는지. 후자는 액션 바를 보여주지 않습니다.

관련 문제