2015-09-19 22 views
9

Sto provando a creare una piccola applicazione convertitore di unità e ho bisogno di più spazio sullo schermo. Dopo aver visto le domande precedenti ho provato a passare il mio layout a una vista lineare e ad aggiungere una vista a scorrimento, ma non riesco ancora ad aggiungere altri elementi alla pagina. Tutto ciò che è contenuto nella vista lineare è ancora impostato alla stessa dimensione dello schermo anche se la finestra scorre.Scroll View - Serve più spazio sullo schermo in Android Studio

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".TestActivity" 
android:id="@+id/scrollView" 
android:fillViewport="false"> 

<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 
<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/temperatureEditText" 
    android:hint="Enter Temperature" 
    android:layout_below="@+id/temperatureTextView" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<RadioGroup 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/radioGroup" 
    android:layout_below="@+id/temperatureEditText" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true"> 

    <RadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="From Celsius to Farenheight" 
     android:id="@+id/toFarenheightRadioButton" 
     android:checked="true" /> 

    <RadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="From Farenheight to Celsius" 
     android:id="@+id/toCelsiusRadioButton" 
     android:checked="false" 
     android:visibility="visible" /> 
</RadioGroup> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Convert" 
    android:id="@+id/convertButton" 
    android:onClick="convert" 
    android:layout_below="@+id/radioGroup" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:text="Temperature Conversion" 
    android:id="@+id/temperatureTextView" 
    android:layout_alignParentTop="true" 
    android:layout_alignRight="@+id/sqFoottextView" 
    android:layout_alignEnd="@+id/sqFoottextView" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:text="Area Conversion" 
    android:id="@+id/sqFoottextView" 
    android:layout_below="@+id/convertButton" 
    android:layout_alignRight="@+id/areaEditText" 
    android:layout_alignEnd="@+id/areaEditText" 
    android:layout_gravity="right" /> 

<EditText 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:inputType="number" 
    android:ems="10" 
    android:id="@+id/areaEditText" 
    android:hint="Enter area" 
    android:layout_below="@+id/sqFoottextView" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<RadioGroup 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/areaEditText" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:id="@+id/areaRadioGroup"> 

    <RadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Sq. ft to Sq. meters" 
     android:id="@+id/toSqMetersRadioButton" 
     android:checked="true" /> 

    <RadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Sq. meters to Sq. feet" 
     android:id="@+id/toSqFeetRadioButton" 
     android:checked="false" /> 
</RadioGroup> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Convert" 
    android:id="@+id/areaButton" 
    android:onClick="areaConvert" 
    android:layout_below="@+id/areaRadioGroup" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:nestedScrollingEnabled="true" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:text="Length Conversions" 
    android:id="@+id/lengthTextView" 
    android:layout_below="@+id/areaButton" 
    android:layout_alignRight="@+id/areaRadioGroup" 
    android:layout_alignEnd="@+id/areaRadioGroup" /> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="number" 
    android:ems="10" 
    android:id="@+id/lengthEditText" 
    android:layout_below="@+id/lengthTextView" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:text="Enter Feet to convert" /> 

<RadioGroup 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/lengthEditText" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:id="@+id/lengthRadioGroup"> 

    <RadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Feet to Miles" 
     android:id="@+id/toMilesRadioButton" 
     android:checked="true" /> 
</RadioGroup> 

<RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Feet to Yards" 
    android:id="@+id/toYardsRadioButton" 
    android:layout_below="@+id/lengthRadioGroup" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:checked="false" /> 
</LinearLayout> 

</ScrollView> 

Come aumentare la lunghezza dello schermo? Ho provato a impostare la lunghezza della vista lineare per riempire il genitore e non ha funzionato neanche.

risposta

1

Modifica android:orientation="horizontal" nel `LinearLayout' permetterà il suo contenuto per riempire il genitore correttamente

5

Devi cambiare l'orientamento orizzontale per

+0

che ha funzionato, grazie! – Ashley