2011-11-21 2 views
0

나는 수평 방향으로 4 개의 이미지가있는 선형 레이아웃을 가지고있다. ?4 개의 이미지가있는 LinearLayout - 나는 구멍이 보이지 않는다.

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 



     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_new_3" 
      android:layout_weight="1" 
       /> 


     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_btn1"       
       /> 

     <ImageButton   
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_btn2"     

      /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_btn3"       

      /> 
    </LinearLayout> 

이 내가 원하는 무엇인가 : 내 문제는 첫 번째 이미지가 잘립니다되고 난 단지하시기 바랍니다 일부 emulators..any 도움에, 내 갤럭시 S에서 둘 다 볼 수 없습니다 것입니다이 내 선형 레이아웃 코드 enter image description here

이 내가 무엇을 얻을 enter image description here

@Jamo : image1에 :

enter image description here

image2,3,4 :

enter image description here

+0

테스트에 도움이되는 이미지를 제공해 주시겠습니까? –

+0

물론, –

답변

0

귀하의 포함 된 레이아웃이 부모의 폭 (아마 전체 화면)으로 제한있어 의미 fill_parent입니다. 각 ImageButton은 너비가 맞는 wrap_content으로 설정됩니다. 사용중인 이미지의 배경 너비가 전체 부모 너비보다 더 많으면 문제가 발생할 수 있습니다. 이것은 무슨 일이 일어나는 것 같습니다. 당신은 가지고있는 것보다 더 많은 픽셀을 화면에 맞출 수 없습니다.

업데이트 : 당신 제공하는 그래픽으로

에서, "안녕하세요"이미지가 138px이고 별이 60 픽셀입니다. 138 + 60 * 3 = 318. 화면이 너비 480 픽셀 (나는 갤럭시 S가 480 와이드라고 생각합니다)이라면 적합 할 수 있어야합니다. 이것을 기본 또는 mdpi 폴더에 넣으면 (갤럭시 S는 hdpi입니다), 이것들은 1.5x, 즉 477px로 스케일됩니다. 그것은 여전히 ​​적합해야합니다.

+0

을 업로드하는 데는 단지 1 초 밖에 걸리지 않으므로 수정하는 유일한 방법은 더 작은 그래픽을 사용하는 것입니다. –

+0

빠른 계산으로 업데이트했습니다. 'LinearLayout'은 실제로 최상위 레이아웃입니까? 아니면 뭔가 다른 것에 포함되어 있습니까? – kabuko

0

이 같은 RelativeLayout의를 사용하는 것입니다 비슷한 것을 만들 알고있는 유일한 방법 :

<RelativeLayout android:layout_height="wrap_content" 
    android:layout_width="fill_parent"> 
    <ImageView android:layout_alignParentRight="true" 
     android:id="@+id/iv4" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/icon"/> 
    <ImageView android:layout_toLeftOf="@id/iv4" 
     android:id="@+id/iv3" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/icon"/> 
    <ImageView android:layout_toLeftOf="@id/iv3" 
     android:id="@+id/iv2" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/icon"/> 
    <ImageView android:layout_toLeftOf="@id/iv2" 
     android:id="@+id/iv1" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:src="@drawable/icon"/> 
</RelativeLayout> 
0

우리는 이전 질문에서 이것에 대해 담소를. 전체 레이아웃 파일을 게시하십시오. layout_weight는 다른 포스트에서 암시 된 것처럼, 전체 너비가 바깥 쪽 LinearLayout의 부모가 무엇이든간에 제약을받는다면별로 도움이되지 않습니다.

또한 몇 가지 생각입니다.

ImageView 높이가 "fill_parent"입니다. 나는 그것들이 "wrap_content"이어야한다고 생각한다. 당신은 'src'가 아닌 '배경'으로 이미지를 설정하고 있습니다. 이것은 이상한 일입니다.

또한 첫 번째 이미지는 다른 레이아웃 컨테이너에 있어야 'hello'가 엉망이되지 않는 늘이기가 가능합니다.

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 


    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:orientation="horizontal" 
     android:layout_weight="1"> 
     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/header_new_3" 
      android:layout_gravity="center" 
      /> 
    </LinearLayout> 

100 % 즉 정확하게 당신이 원하는 것,하지만 궁극적 인 목표는 어떤 방법으로 그것을 전단 않고 첫 번째 이미지를 스트레칭하는 것에 확인합니다.

관련 문제