0

Чтобы просмотреть все элементы внутри моего релятивирования на небольших экранах, я сделал выбор, чтобы использовать scrollview, чтобы сделать это возможным (или, по крайней мере, попытаться выполнить это). Проблема: я не могу прокручивать. Результат наличия или отсутствия прокрутки одинаковый, если экран небольшой, некоторые элементы будут обрезаны (это было бы хорошо, если бы прокрутка была возможна). В некоторых поисках я сталкивался с некоторыми scrollview с реализациями linearlayout, но в моем случае я думаю, что это не очень хорошо, потому что мне нужны флажки, выровненные справа от текста.Scrollview, который не прокручивается

Heres XML, что я до сих пор:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#231E1A" 
    android:keepScreenOn="true" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:ignore="ContentDescription" 
    android:fillViewport="true"> 

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

    <Button 
     android:id="@+id/btn_getDirections" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:text="@string/btn_getDirections" /> 

    <TextView 
     android:id="@+id/static_language" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/radioGroup" 
     android:layout_alignLeft="@+id/radioGroup" 
     android:text="@string/static_language" 
     android:paddingTop="10dp" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textColor="#FFFFFF" /> 

    <AutoCompleteTextView 
     android:id="@+id/aComplete_destination" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/static_language" 
     android:layout_alignLeft="@+id/static_language" 
     android:ems="10" 
     android:inputType="textNoSuggestions" 
     android:text="@string/aComplete_destination" /> 


    <TextView 
     android:id="@+id/static_destination" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/aComplete_destination" 
     android:layout_alignLeft="@+id/aComplete_destination" 
     android:text="@string/static_destination" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textColor="#FFFFFF" /> 

    <TextView 
     android:id="@+id/static_highways" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/static_destination" 
     android:layout_alignLeft="@+id/static_destination" 
     android:paddingBottom="10dp" 
     android:text="@string/static_highways" 
     android:textColor="#FFFFFF" 
     android:textSize="20sp" /> 

    <TextView 
     android:id="@+id/static_tolls" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/static_highways" 
     android:layout_alignLeft="@+id/static_highways" 
     android:paddingBottom="10dp" 
     android:paddingTop="10dp" 
     android:text="@string/static_tolls" 
     android:textColor="#FFFFFF" 
     android:textSize="20sp" /> 

    <TextView 
     android:id="@+id/static_useCurrentLocation" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/static_tolls" 
     android:layout_alignLeft="@+id/static_tolls" 
     android:paddingTop="10dp" 
     android:text="@string/static_useCurrentLocation" 
     android:textColor="#FFFFFF" 
     android:textSize="20sp" /> 

    <AutoCompleteTextView 
     android:id="@+id/aComplete_origin" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/static_useCurrentLocation" 
     android:layout_alignLeft="@+id/static_useCurrentLocation" 
     android:ems="10" 
     android:inputType="textNoSuggestions" 
     android:text="@string/aComplete_origin" > 
     <requestFocus /> 
    </AutoCompleteTextView> 

    <TextView 
     android:id="@+id/static_origin" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/aComplete_origin" 
     android:layout_alignLeft="@+id/aComplete_origin" 
     android:text="@string/static_origin" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textColor="#FFFFFF" /> 

    <ImageView 
     android:id="@+id/logo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/static_origin" 
     android:layout_alignLeft="@+id/static_origin" 
     android:layout_alignParentTop="true" 
     android:paddingBottom="10dp" 
     android:scaleType="fitStart" 
     android:src="@drawable/logo" /> 

    <CheckBox 
     android:id="@+id/tolls_checkbox" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/static_tolls" 
     android:layout_alignBottom="@+id/static_tolls" 
     android:layout_alignParentRight="true" 
     android:text="@string/checkbox" /> 

    <CheckBox 
     android:id="@+id/highways_checkbox" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/static_highways" 
     android:layout_alignBottom="@+id/static_highways" 
     android:layout_alignParentRight="true" 
     android:text="@string/checkbox" /> 

    <CheckBox 
     android:id="@+id/useLocation_checkbox" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/static_useCurrentLocation" 
     android:layout_alignBottom="@+id/static_useCurrentLocation" 
     android:layout_alignParentRight="true" 
     android:text="@string/checkbox" /> 

    <RadioGroup 
     android:id="@+id/radioGroup" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/btn_getDirections" 
     android:layout_alignLeft="@+id/btn_getDirections" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/radio_english" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:textColor="#FFFFFF" 
      android:layout_marginRight="20dp" 
      android:text="@string/radio_english" /> 

     <RadioButton 
      android:id="@+id/radio_portugues" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#FFFFFF" 
      android:text="@string/radio_portugues" /> 
    </RadioGroup> 
</RelativeLayout> 
</ScrollView> 

ответ

0

ура! Я заработал! Это была комбинация: linearlayout, scrollview и relativelayout. Теперь он отлично прокручивается, когда экран не достаточно большой, чтобы просмотреть полный контент. Я предполагаю, что переход на linearlayout был на самом деле ключевым в этом. В основном я применил то, что было указано в сайте разработчика: http://developer.android.com/reference/android/widget/ScrollView.html

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

XML-:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#231E1A" 
    android:keepScreenOn="true" 
    android:scrollbars="none" 
    android:overScrollMode="never" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:ignore="ContentDescription" 
    android:fillViewport="true"> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="bottom" 
    android:keepScreenOn="true" 
    android:orientation="vertical" > 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="80dp" 
     android:id="@+id/logo" 
     android:scaleType="fitStart" 
     android:src="@drawable/logo"/> 

    <TextView 
     android:id="@+id/static_origin" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/static_origin" 
     android:paddingTop="10dp" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textColor="#FFFFFF" /> 

    <AutoCompleteTextView 
     android:id="@+id/aComplete_origin" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:inputType="textNoSuggestions" 
     android:text="@string/aComplete_origin" > 
     <requestFocus /> 
    </AutoCompleteTextView> 

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

     <TextView 
      android:id="@+id/static_useCurrentLocation" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:textColor="#FFFFFF" 
      android:textSize="20sp" 
      android:paddingTop="10dp" 
      android:text="@string/static_useCurrentLocation" /> 

     <TextView 
      android:id="@+id/static_tolls" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@+id/static_useCurrentLocation" 
      android:layout_below="@+id/static_useCurrentLocation" 
      android:textColor="#FFFFFF" 
      android:textSize="20sp" 
      android:paddingBottom="10dp" 
      android:paddingTop="10dp"   
      android:text="@string/static_tolls" /> 

     <TextView 
      android:id="@+id/static_highways" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/static_tolls" 
      android:layout_alignLeft="@+id/static_tolls" 
      android:paddingBottom="10dp" 
      android:text="@string/static_highways" 
      android:textColor="#FFFFFF" 
      android:textSize="20sp" />   

     <CheckBox 
      android:id="@+id/tolls_checkbox" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/static_tolls" 
      android:layout_alignBottom="@+id/static_tolls" 
      android:layout_alignParentRight="true" 
      android:text="@string/checkbox" /> 

     <CheckBox 
      android:id="@+id/highways_checkbox" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/static_highways" 
      android:layout_alignBottom="@+id/static_highways" 
      android:layout_alignParentRight="true" 
      android:text="@string/checkbox" /> 

     <CheckBox 
      android:id="@+id/useLocation_checkbox" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@+id/static_useCurrentLocation" 
      android:layout_alignBottom="@+id/static_useCurrentLocation" 
      android:layout_alignParentRight="true" 
      android:text="@string/checkbox" />  

    </RelativeLayout> 

    <TextView 
     android:id="@+id/static_destination" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/static_destination" 
     android:textColor="#FFFFFF" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <AutoCompleteTextView 
     android:id="@+id/aComplete_destination" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:inputType="textNoSuggestions" 
     android:text="@string/aComplete_destination" /> 

    <TextView 
     android:id="@+id/static_language" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/static_language" 
     android:textColor="#FFFFFF" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <RadioGroup 
     android:id="@+id/radioGroup" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/radio_english" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:textColor="#FFFFFF" 
      android:layout_marginRight="20dp" 
      android:text="@string/radio_english" /> 

     <RadioButton 
      android:id="@+id/radio_portugues" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textColor="#FFFFFF" 
      android:text="@string/radio_portugues" /> 
    </RadioGroup> 

    <Button 
     android:id="@+id/btn_getDirections" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/btn_getDirections" /> 

</LinearLayout> 

</ScrollView> 
Смежные вопросы