2012-12-16 3 views
0

표시되지 않습니다안드로이드 : 이미지 뷰 나는이 레이아웃 사용하고

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:textColor="#372c24" /> 

    <View 
     android:id="@+id/space" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="5" 
     android:background="@android:color/transparent" /> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="4" 
     android:orientation="horizontal" 
     android:background="@drawable/shape_popup"> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" /> 
     <ImageView 
      android:contentDescription="@string/app_name" 
      android:id="@+id/rateStar" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      android:background="@drawable/image" /> 
    </LinearLayout> 

</LinearLayout> 

을하지만 이미지가 표시되지 않는 이유는 무엇입니까? 그것은 몇 가지 소스가 그래서 당신은 무게를주는로 필요하지 않는 한이

android:src="@drawable/image" 

은 또한 당신의 텍스트 뷰의 폭을 수정 사용 얻을 때까지

+2

android : src = "@ drawable/image" –

+0

@Matt Clark : 작동합니다, 감사합니다 :) –

+0

문제 없습니다! 해피 코딩! :) <<< 나는 약간 더 자세한 설명으로 대답을 던졌다 : p –

답변

1

ImageBiew는 못해 아무것도 표시합니다.

  <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" /> 
0

당신은 안드로이드를 사용한다 : SRC 대신 안드로이드의 :

<ImageView 
     android:contentDescription="@string/app_name" 
     android:id="@+id/rateStar" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:src="@drawable/image" /> 

편집 : 당신이 무게 속성을 사용하고 있기 때문에 0 layout_width : 은 또한 당신이 안드로이드를 설정해야합니다

이 같은 배경
 <ImageView 
     android:contentDescription="@string/app_name" 
     android:id="@+id/rateStar" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="2" 
     android:src="@drawable/image" /> 
1

당신은 재산 사용하는 경우 :

android:background="" 

일반적으로 # FFFF0000 < - 빨강과 같이 색상 같은 것을 찾고 이미지로 컨테이너를 채우지 않습니다. 당신은 또한 컨테이너 내에서 이미지의 서로 다른 규모의 유형을 변경하려면 android:scaleType="..."

을 사용할 수 있습니다 이것으로 android:src="@drawable/..."

:

적절한 피팅 용기에 이미지를 얻으려면, 당신은 속성을 사용해야합니다.

+0

'background' 속성에'drawable '을 설정하는 데 아무런 문제가 없다. 안드로이드는'ImageView'에서'background'와'src'를 조금 다르게 처리합니다. – Rawkode

관련 문제