2015-01-24 2 views
-1

탐색 서랍이있는 프로젝트에서 작업하고 있습니다. 탐색 서랍에서 listivew 위에 이미지 뷰를 배치하려고합니다. xml 레이아웃은 다음과 같습니다.안드로이드의 탐색 서랍 안에 이미지 뷰가 있음

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <!-- The main content view --> 

    <FrameLayout 
     android:id="@+id/frame_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 
    <!-- The navigation drawer --> 
    <RelativeLayout 
     android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:orientation="vertical" 
     android:clickable="true" 
     > 
     <ImageView 
      android:id="@+id/image_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/ic_logo" /> 

    <ListView 
     android:id="@+id/slider_list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#CC000000" 
     android:choiceMode="singleChoice" 
     android:divider="#808080" 
     android:layout_below="@id/image_view" 
     android:dividerHeight="0.5dp" 
     /> 
</RelativeLayout> 
</android.support.v4.widget.DrawerLayout> 

문제는 이미지 뷰가 기기에서 실행 중 스 퀴드/압축으로 표시된다는 것입니다. 압축 된 것으로 보이는 이유는 무엇입니까? 제발 도와주세요 !!

+0

장치에서 보이는 모습을 게시하여 문제를보다 명확하게 이해할 수있게하십시오. –

+0

당신의'Imageview'의 높이가'wrap_content'이고 당신이 당신의 앱을 실행하고있는 장치의 높이를 지정하지 않았습니다. 이 문제는 화면 해상도가 다르기 때문에 발생합니다. 큰 장치 이미지에서 부숴 질 것입니다. 그래서 당신은'ImageView'에 고정 된 높이를 적용해야합니다. – Piyush

+0

이미지보기의 높이를 지정하거나 압축 된 이미지를 사용하여 원하는대로 이미지의 높이와 너비를 고정 – Prabhakar

답변

0

이미지보기 너비가 "match_parent"로 설정되고 높이가 "wrap_content"로 설정되어 이미지가 장치와 동일한 너비가 아닌 경우 이미지가 가로로 늘어납니다. 너비 설정 필요한 경우 "wrap_content"로 이미지를 가운데에 놓습니다. 또한

...

당신이 줄 제거해야하므로 상대 레이아웃 방향이없는 -

android:orientation="vertical" 
+0

네비게이션 서랍의 너비와 일치하므로 이미지의 너비를 match_parent로 설정합니다. –

0

사용하여 이미지 뷰에서이 속성 : 또한

android:adjustViewBounds="true" 

를 사용 Drawable의 src 속성 (배경 속성이 아님) :

android:src="@drawable/my_drawable" 
+0

나는 위의, didnt 일을 시도했다. :( –