2012-08-08 4 views
0

내 앱에 TabHost가 있고 인스턴트 이미지를 넣으려고합니다. 제 문제는 이미지가 실제 크기가 아닌 전체 화면으로 늘어나고 있다는 것입니다. 메신저 hight과 너비에서 "wrap_content"를 사용하여 여전히 그것을하고 있습니다. 인스턴트 메신저 때 같은 이미지를 다른 물건을 "wrap_content"그 괜찮아. 탭에서만 이상합니다. 그것은 본다 그게 전부 방법 :이미지가 탭에서 펼쳐져 있습니다. android

<TabHost 
    android:id="@+id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="wrap_content" 
       android:layout_height="60dp" 
       android:gravity="center_vertical" 
       android:showDividers="none" > 

      </TabWidget> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 

      <LinearLayout 
       android:id="@+id/tab1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <Button 
        android:id="@+id/button1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="start" /> 

       <Button 
        android:id="@+id/button2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="stop" /> 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="first tab" /> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/tab2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <Button 
        android:id="@+id/button3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="second tab B" /> 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Secont tab" /> 

      </LinearLayout> 
     </FrameLayout> 
    </LinearLayout> 
</TabHost> 

감사 :

enter image description here

내 코드를 먹으 렴 :

대신 다음과 같이 보는 enter image description here

!

답변

2

이미지보기를 다음과 같이 자바 코드에서 확대/축소 해보십시오.

yourImageView.setScaleType(ScaleType.CENTER); 

또는 이와 유사한 XML;

android:scaleType="fitCenter" 
1

나는과 같이 상대 레이아웃을 사용하여 고정 :

<TabHost 
    android:id="@+id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.8" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="0.1" > 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="false" 
       android:layout_centerHorizontal="true" 
       android:gravity="center_vertical" 
       android:showDividers="none" > 
      </TabWidget> 

     </RelativeLayout> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="0.9" > 

      <LinearLayout 
       android:id="@+id/tab1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <Button 
        android:id="@+id/button1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="start" /> 

       <Button 
        android:id="@+id/button2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="stop" /> 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="first tab" /> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/tab2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <Button 
        android:id="@+id/button3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="second tab B" /> 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Secont tab" /> 

      </LinearLayout> 
     </FrameLayout> 
    </LinearLayout> 
</TabHost> 

감사 어쨌든!

1

매우 늦은 답변이며 더 이상 신경 쓰지 않지만 다른 사람에게 도움이 될 것이라고 확신합니다. 여기

는 아홉 패치 생성기는 신속하게 지정된 소스 작품에 따라 다른 화면 밀도에서 간단한 아홉 패치를 생성 할 수 있습니다이

또 다른 Link입니다.

이 부분에 문제가 있으면 Here입니다. CommonsWare 답하십시오.

관련 문제