2012-11-11 4 views
0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/linearLayout" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center_horizontal" 
    android:background="@color/background_color"> 

    <TextView android:id="@+id/titleTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/quiz_title" 
     android:layout_marginBottom="2dp" 
     android:textSize="@dimen/title_size" 
     android:textColor="@color/text_color" 
     android:gravity="center"> 
    </TextView> 

    <TextView android:id="@+id/questionNumberTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="2dp" 
     android:layout_marginTop="2dp" 
     android:textColor="@color/text_color" 
     android:textSize="@dimen/text_size" 
     android:layout_gravity="center" 
     android:gravity="center"></TextView> 


    <ScrollView android:id="@+id/SlotScrollView" 
    android:layout_width="match_parent"   
    android:padding="0dp">   
     <ImageView android:id="@+id/flagImageView" 
     android:adjustViewBounds="false" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/flag_height"> 
     </ImageView> 
    <ScrollView 

    <TextView android:id="@+id/guessCountryTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="2dp" 
     android:layout_marginTop="2dp" 
     android:text="@string/choose_answer" 
     android:textColor="@color/text_color" 
     android:textSize="@dimen/text_size"></TextView> 


    <TableLayout android:id="@+id/buttonTableLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:stretchColumns="0,1,2,3"> 
     <TableRow android:id="@+id/tableRow0" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"></TableRow> 
     <TableRow android:id="@+id/tableRow1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"></TableRow> 
     <TableRow android:id="@+id/tableRow2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"></TableRow> 
    </TableLayout> 

    <TextView android:id="@+id/answerTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textSize="@dimen/answer_size" 
     android:layout_gravity="center" 
     android:textStyle="bold" 
     android:gravity="center"></TextView> 

</LinearLayout> 

난 그냥 이미지의 폭이 화면 너비보다 작은 경우 1. 이미지를 확장 할 것 같은 이미지 뷰를 극대화하고 화면의 폭과 동일 극대화하고자 2 이미지 높이가 사용 가능한 공간보다 크면 위 아래로 스크롤 효과가 발생합니다. 3. 이미지 아래의 guessCountryTextView 및 모든 구성 요소가 표시되고 화면 아래에 배치되어야합니다.안드로이드 - 레이아웃 - 극대화 이미지 뷰

그러나 위의 코드처럼 scrollview를 추가하면 scrollview가 imageview에서 시작되는 전체 화면을 차지하고 guessCountryTextView와 같은 해당 영역이 모두 사라집니다.

어떻게 수정할 수 있습니까? 많은 감사합니다!

답변

0

선형 레이아웃 대신 relativelayout을 사용해보십시오. scroll_view에 대한 match_parent widht와 고정 높이를 사용하는 것은 모두 내가 생각할 필요가있다. 코드를 살펴보면 몇 가지 조정을해야 할 것이다.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/linearLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/darker_gray" > 

    <TextView 
     android:id="@+id/titleTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:text="afafafafa" 
     android:textColor="@android:color/darker_gray" 
     android:textSize="20sp" > 
    </TextView> 

    <TextView 
     android:id="@+id/questionNumberTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/titleTextView" 
     android:layout_gravity="center" 
     android:textColor="@android:color/darker_gray" 
     android:textSize="20sp" > 
    </TextView> 

    <ScrollView 
     android:id="@+id/SlotScrollView" 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
     android:layout_below="@+id/questionNumberTextView" 
     android:padding="0dp" 
     android:color="@android:color/black" > 

     <ImageView 
      android:id="@+id/flagImageView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="false" > 
     </ImageView> 
    </ScrollView> 

    <TextView 
     android:id="@+id/guessCountryTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="2dp" 
     android:layout_marginTop="2dp" 
     android:text="sfsff" 
     android:textColor="@android:color/darker_gray" 
     android:textSize="20sp" > 
    </TextView> 

    <TableLayout 
     android:id="@+id/buttonTableLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:stretchColumns="0,1,2,3" > 

     <TableRow 
      android:id="@+id/tableRow0" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 
     </TableRow> 

     <TableRow 
      android:id="@+id/tableRow1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 
     </TableRow> 

     <TableRow 
      android:id="@+id/tableRow2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 
     </TableRow> 
    </TableLayout> 

    <TextView 
     android:id="@+id/answerTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_toRightOf="@+id/buttonTableLayout" 
     android:textSize="20sp" 
     android:textStyle="bold" > 
    </TextView> 

</RelativeLayout> 
관련 문제