2016-11-19 6 views
-1

Что я пытаюсь достичь этого:Несколько линейных макетов с прокруткой?

enter image description here

Но что у меня есть:

<?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:layout_width="290dp" 
    android:layout_height="490dp" 
    android:layout_marginLeft="35dp" 
    android:layout_marginTop="40dp" 
    android:background="#2a873e" 
    tools:context="com.sumo.traffic.PlacesFilters" 
    android:orientation="vertical"> 

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

     <Button 
      android:id="@+id/button1" 
      android:layout_width="0px" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" 
      android:text="Button" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="0px" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.6" 
      android:text="Button" /> 

    </LinearLayout> 


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

     <Button 
      android:id="@+id/button3" 
      android:layout_width="0px" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" 
      android:text="Button" /> 

     <Button 
      android:id="@+id/button4" 
      android:layout_width="0px" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.6" 
      android:text="Button" /> 

    </LinearLayout> 



</LinearLayout> 

При нанесении прокрутки просмотра показывает, что вид прокрутки может размещаться только один один макет , Будет ли еще один способ создать то, что я хочу достичь?

Я помещаю более 10 кнопок в одном действии, поэтому мне нужен прокрутка в моем макете.

ответ

0

Попробуйте использовать это:

<?xml version="1.0" encoding="utf-8"?> 


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 
    <ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

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

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

      <Button 
       android:id="@+id/button1" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="Button" /> 

      <Button 
       android:id="@+id/button2" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       android:text="Button" /> 
     </LinearLayout> 

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

      <Button 
       android:id="@+id/button3" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="Button" /> 

      <Button 
       android:id="@+id/button4" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       android:text="Button" /> 
     </LinearLayout> 
    </LinearLayout> 
</ScrollView></LinearLayout> 
0

Попробуйте так:

<?xml version="1.0" encoding="utf-8"?> 
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="width" 
     android:layout_height="height" 
    android:background="#2a873e" 
     tools:context="com.sumo.traffic.PlacesFilters" 
    android:layout_marginLeft="35dp" 
     android:layout_marginTop="40dp"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 

     android:orientation="vertical"> 

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

      <Button 
       android:id="@+id/button1" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="Button" /> 

      <Button 
       android:id="@+id/button2" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       android:text="Button" /> 

     </LinearLayout> 


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

      <Button 
       android:id="@+id/button3" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.4" 
       android:text="Button" /> 

      <Button 
       android:id="@+id/button4" 
       android:layout_width="0px" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.6" 
       android:text="Button" /> 
     </LinearLayout> 
    </LinearLayout> 
    <ScrollView> 
Смежные вопросы