2014-04-17 4 views
0

이미지가있는 Customer Spinner가 있습니다. 현재 모든 것이 두 가지 작은 것을 제외하고 의도적으로 작동하고 있습니다.Android Spinner 이미지 처리 완료

  1. 작은가는 선을 제외하고 회 전자가 표시되지 않습니다.
  2. 회 전자 항목은 회색 테두리가 약간 늘어납니다. 아래에 이러한 문제

내가 추가 한 스크린 샷 :

enter image description hereenter image description here

내가 원하는 것은 대신 위의 작은 얇은 라인의

  1. , 나는 빈 체크 박스를 원하는 아래 이미지처럼 이미지.
  2. Spinner 항목의 이미지 오른쪽이 회색 부분이므로 제거해야합니다.

나는이 두 가지 문제가 XML 파일에 있음을 알고 있지만 안드로이드에 익숙하지 않으며 항상 layout_widht/height와 혼동하는 경우가 있습니다.

activity_main.xml :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:orientation="vertical" 
    tools:context="com.example.testproject.MainActivity$PlaceholderFragment" > 

    <Spinner 
     android:id="@+id/spCheckbox" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="15dp" 
     android:drawSelectorOnTop="true" /> 

    <ImageButton 
      android:id="@+id/ibtnCheckbox" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="15dp" 
      android:contentDescription="@string/checkbox_content_description" 
      android:src="@drawable/checkbox_unchecked" 
      android:background="@drawable/transparent_background" /> 

</LinearLayout> 

spinner_item.xml : 그래서

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:id="@+id/cbImage" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:background="@drawable/transparent_button_background" /> 

</RelativeLayout> 

(transparent_background.xml :

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_selected="true" android:drawable="@android:color/transparent" /> 
    <item android:state_pressed="true" android:drawable="@android:color/transparent" /> 
    <item android:drawable="@android:color/transparent" /> 
</selector> 

여기

는 XML 파일 .. 어떤 layout_wid th/layout_height 적절한 결과를 얻으려면 변경해야합니까?

미리 답변 해 주셔서 감사합니다.

EDIT : 필자는 약간의 연구를했고 fill_parent를 match_parent로 바꾸기 시작했다. (같은 것이기 때문에 fill_parent는 API lvl.8 이후 사용되지 않기 때문에). 내 문제는 내 activity_main 레이아웃이 match_parent이어야 전체 화면이되고 Spinner, Spinner Item의 레이아웃 및 Spinner Item의 ImageView가 모두 wrap_content 여야합니다.

그래도 변경하면 두 가지 문제가 동일하게 유지됩니다. Spinner의 선택한 이미지를 표시하는 방법과 Spinner 항목의 회색 간격을 제거하는 방법을 알고 있다면 알려주십시오.

답변

0

대신 스피너의 얇은 라인의 문제가 해결 .. 나는 그들이 라인 추가 인터넷에 어딘가에 자습서를 다음 때 그것은 밝혀 :

spinner.getLayoutParams().width = 3; 

이 줄을 제거를, 분명히, 고정 첫 번째 문제는 ..>.> (왜 그들이 처음에 이것을 추가했는지 정직하지 못했지만 지금은 사라졌습니다.)

이제 두 번째 문제를 해결해야합니다. 회색 테두리가 있지만 결국에는 해결책을 찾을 수있을 것이라고 확신합니다.

편집 : 회색 패딩 외에 회 전체 오른쪽 아래 화살표를 제거하고 싶었 기 때문에 Spinner를 완전히 제거하고 수직 방향이있는 LineairLayout을 사용하여 팝업을 작성하기로 결정했습니다.

코드를 참조하기 위해 another question of mine에 게시했습니다.