2015-08-29 4 views
0

Это мой кодScrollView реализует более 1 RelativeLayout

мне нужно сделать это выглядеть без Scrollview не суммируется до я не могу сделать мой LinearLayout Xmlns: андроид для прокрутки вида, потому что я не хочу, чтобы мой чтобы начать перемещение.


 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:tools="http://schemas.android.com/tools" 
 
    android:layout_width="wrap_content" 
 
    android:layout_height="wrap_content" 
 
    android:fillViewport="true" 
 
    android:gravity="center_horizontal" 
 
    android:orientation="vertical" 
 
    android:weightSum="1" 
 
    tools:context=".HistoryScreen"> 
 

 
    <android.support.v7.widget.Toolbar 
 
     android:id="@+id/toolbar" 
 
     android:layout_width="370dp" 
 
     android:layout_height="64dp" 
 
     android:background="@color/ColorPrimary" 
 
     android:minHeight="?attr/actionBarSize" 
 
     android:scrollbars="none"> 
 

 
     <TextView 
 
      android:id="@+id/toolbar_title" 
 
      android:layout_width="wrap_content" 
 
      android:layout_height="wrap_content" 
 
      android:text="@string/app_history" 
 
      android:textColor="@color/TitleColor" 
 
      android:textSize="22sp" /> 
 

 
    </android.support.v7.widget.Toolbar> 
 

 

 
    <ScrollView 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent"> 
 

 
     <RelativeLayout 
 
      android:layout_width="wrap_content" 
 
      android:layout_height="wrap_content"> 
 

 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content"> 
 

 
       <TextView 
 
        android:id="@+id/description_text" 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        android:maxLines="5" 
 
        android:text="@string/History3" /> 
 

 
       <ImageButton 
 
        android:id="@+id/show" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_alignParentRight="true" 
 
        android:layout_below="@+id/description_text" 
 
        android:background="@drawable/arrow_down" 
 
        android:clickable="true" /> 
 

 
       <View 
 
        android:id="@+id/view" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="2dp" 
 
        android:layout_below="@+id/description_text" 
 
        android:layout_marginTop="5dp" 
 
        android:layout_toLeftOf="@+id/show" 
 
        android:background="#000" /> 
 

 
       <ImageButton 
 
        android:id="@+id/hide" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_alignParentRight="true" 
 
        android:layout_below="@+id/description_text" 
 
        android:background="@drawable/arrow_up" 
 
        android:clickable="true" 
 
        android:visibility="invisible" /> 
 
      </RelativeLayout> 
 

 

 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content"> 
 

 
       <TextView 
 
        android:id="@+id/description_text1" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_below="@id/description_text1" 
 
        android:maxLines="5" 
 
        android:text="@string/History2" /> 
 

 
       <ImageButton 
 
        android:id="@+id/show1" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_alignParentRight="true" 
 
        android:layout_below="@+id/description_text1" 
 
        android:background="@drawable/arrow_down" 
 
        android:clickable="true" /> 
 

 
       <View 
 
        android:id="@+id/view1" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="2dp" 
 
        android:layout_below="@+id/description_text1" 
 
        android:layout_marginTop="5dp" 
 
        android:layout_toLeftOf="@+id/show1" 
 
        android:background="#000" /> 
 

 
       <ImageButton 
 
        android:id="@+id/hide1" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_alignParentRight="true" 
 
        android:layout_below="@+id/description_text1" 
 
        android:background="@drawable/arrow_up" 
 
        android:clickable="true" 
 
        android:visibility="invisible" /> 
 
      </RelativeLayout> 
 

 

 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content"> 
 

 
       <TextView 
 
        android:id="@+id/description_text2" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_below="@id/description_text2" 
 
        android:maxLines="5" 
 
        android:text="@string/history4"> 
 

 
       </TextView> 
 

 
       <ImageButton 
 
        android:id="@+id/show2" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_alignParentRight="true" 
 
        android:layout_below="@+id/description_text2" 
 
        android:background="@drawable/arrow_down" 
 
        android:clickable="true" /> 
 

 
       <View 
 
        android:id="@+id/view2" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="2dp" 
 
        android:layout_below="@+id/description_text2" 
 
        android:layout_marginTop="5dp" 
 
        android:layout_toLeftOf="@+id/show2" 
 
        android:background="#000" /> 
 

 
       <ImageButton 
 
        android:id="@+id/hide2" 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:layout_alignParentRight="true" 
 
        android:layout_below="@+id/description_text2" 
 
        android:background="@drawable/arrow_up" 
 
        android:clickable="true" 
 
        android:visibility="invisible" /> 
 

 
      </RelativeLayout> 
 
     </RelativeLayout> 
 
    </ScrollView> 
 
</LinearLayout>'

[1]: http://i.stack.imgur.com/bHtXq.png(Without ScrollView) [2]: http://i.stack.imgur.com/YBcRz.png(With ScrollView)

+0

Ваши вопросы мне кажутся немного неясными. Чего именно вы хотите достичь? –

+0

у вас не может быть более одного прямого дочернего элемента прокрутки. – Tauqir

ответ

0

Просто измените ваш RelativeLayout внутри ScrollView к LinearLayout с android:orientation="vertical" и он должен работать.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    android:gravity="center_horizontal" 
    android:orientation="vertical" 
    android:weightSum="1" 
    tools:context=".HistoryScreen"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="370dp" 
     android:layout_height="64dp" 
     android:background="@color/ColorPrimary" 
     android:minHeight="?attr/actionBarSize" 
     android:scrollbars="none"> 

     <TextView 
      android:id="@+id/toolbar_title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/app_history" 
      android:textColor="@color/TitleColor" 
      android:textSize="22sp" /> 

    </android.support.v7.widget.Toolbar> 


    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

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

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:id="@+id/description_text" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:maxLines="5" 
        android:text="@string/History3" /> 

       <ImageButton 
        android:id="@+id/show" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/description_text" 
        android:background="@drawable/arrow_down" 
        android:clickable="true" /> 

       <View 
        android:id="@+id/view" 
        android:layout_width="wrap_content" 
        android:layout_height="2dp" 
        android:layout_below="@+id/description_text" 
        android:layout_marginTop="5dp" 
        android:layout_toLeftOf="@+id/show" 
        android:background="#000" /> 

       <ImageButton 
        android:id="@+id/hide" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/description_text" 
        android:background="@drawable/arrow_up" 
        android:clickable="true" 
        android:visibility="invisible" /> 
      </RelativeLayout> 


      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:id="@+id/description_text1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/description_text1" 
        android:maxLines="5" 
        android:text="@string/History2" /> 

       <ImageButton 
        android:id="@+id/show1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/description_text1" 
        android:background="@drawable/arrow_down" 
        android:clickable="true" /> 

       <View 
        android:id="@+id/view1" 
        android:layout_width="wrap_content" 
        android:layout_height="2dp" 
        android:layout_below="@+id/description_text1" 
        android:layout_marginTop="5dp" 
        android:layout_toLeftOf="@+id/show1" 
        android:background="#000" /> 

       <ImageButton 
        android:id="@+id/hide1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/description_text1" 
        android:background="@drawable/arrow_up" 
        android:clickable="true" 
        android:visibility="invisible" /> 
      </RelativeLayout> 


      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:id="@+id/description_text2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/description_text2" 
        android:maxLines="5" 
        android:text="@string/history4"> 

       </TextView> 

       <ImageButton 
        android:id="@+id/show2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/description_text2" 
        android:background="@drawable/arrow_down" 
        android:clickable="true" /> 

       <View 
        android:id="@+id/view2" 
        android:layout_width="wrap_content" 
        android:layout_height="2dp" 
        android:layout_below="@+id/description_text2" 
        android:layout_marginTop="5dp" 
        android:layout_toLeftOf="@+id/show2" 
        android:background="#000" /> 

       <ImageButton 
        android:id="@+id/hide2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/description_text2" 
        android:background="@drawable/arrow_up" 
        android:clickable="true" 
        android:visibility="invisible" /> 

      </RelativeLayout> 
     </RelativeLayout> 
    </ScrollView> 
</LinearLayout> 
+0

Спасибо, что это работает! :) – GiveChance

+0

Если это так, то вы можете отметить его как принятый ответ. Чтобы люди, которые наткнулись на этот вопрос в будущем, могут извлечь выгоду из того же. :) – Antrromet

Смежные вопросы