2

我有這個佈局,因爲沒有顯示horizo​​ntalscrollview: 基本上在第一個容器有兩個兒童佈局,第一個是固定的,第二個應該水平滾動但是第二個沒有出現。android-linearlayout在horizo​​ntalscrollview內不起作用

的@繪製/ disattivato包含:

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<gradient 
      android:startColor="#333333" 
    android:endColor="#000000" 
    android:type="radial" 
    android:gradientRadius="500"/> 

    <stroke 
       android:dashGap="10px" 
       android:dashWidth="10px" 
       android:width="1dp" 
       android:color="#ababb2" /> 
</shape> 

這是我的佈局:

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

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:weightSum="8" > 

       <TextView 
        android:id="@+id/tv1" 
        android:layout_width="fill_parent" 
        android:layout_height="0dip" 
        android:layout_weight="1" 
        android:background="@drawable/backgroundbutton" 
        android:gravity="center" 
        android:text="kick11" 
        android:textColor="#000000" 
        android:textSize="8pt" 
        android:textStyle="bold" /> 

      other textviews... 

    </LinearLayout> 

     <HorizontalScrollView 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:fillViewport="true" > 

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

          <LinearLayout 
           android:layout_width="fill_parent" 
           android:layout_height="0dip" 
           android:layout_weight="1" 
           android:orientation="horizontal" > 

           <ImageView 
            android:id="@+id/im11" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:adjustViewBounds="false" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im12" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im13" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im14" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im15" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im16" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im17" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im18" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im19" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im110" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im111" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im112" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im113" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im114" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im115" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/im116" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/buf" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/buf1" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/buf2" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/buf3" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/buf4" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

           <ImageView 
            android:id="@+id/buf5" 
            android:layout_width="wrap_content" 
            android:layout_height="fill_parent" 
            android:background="@drawable/disattivato" 
            android:scaleType="fitXY" /> 

          </LinearLayout> 
        other linear layouts with the same exactly structure 

      </LinearLayout> 
     </HorizontalScrollView> 

+0

我做到了,但仍然沒有出現水平滾動...是正確的android設置圖像列表:layout_width =「wrap_content」? – Nadir

+0

旁邊的線性佈局 – Nadir

回答

1

一個基本的輪廓爲你的佈局如下。請密切關注您在View上設置wrap_contentmatch_parent的位置,因爲這是造成問題的原因。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/tv1" 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_weight="1" 
      android:background="@drawable/backgroundbutton" 
      android:gravity="center" 
      android:text="kick11" 
      android:textColor="#000000" 
      android:textSize="8pt" 
      android:textStyle="bold" /> 

    </LinearLayout> 

    <HorizontalScrollView 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:fillViewport="true" > 

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

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="0dip" 
       android:layout_weight="1" 
       android:orientation="horizontal" > 

       <ImageView 
        android:id="@+id/im11" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:adjustViewBounds="false" 
        android:background="@drawable/disattivato" 
        android:scaleType="fitXY" /> 

       <ImageView 
        android:id="@+id/im12" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/disattivato" 
        android:scaleType="fitXY" /> 

       ... 
       ... 

      </LinearLayout> 

      ... 
      ... 

     </LinearLayout> 

    </HorizontalScrollView> 

</LinearLayout> 
相關問題