Reputation: 11
I tried to delete margins and added a padding button, but those showed no effect. I'm using ScrollView with Relative layout inside of it but when I lunch emulator it shows that part of my screen is cut off. I read similar articles about it but they couldn't help me.
`<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding_bottom="10dp">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="5dp"
android:paddingBottom="5dp" tools:context=".MainActivity"
android:padding="0dp"
android:clickable="true"
android:background="@drawable/shape">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_name"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:paddingTop="15dp"
android:textColorHint="#ffffff"
android:textIsSelectable="false"
android:layout_toRightOf="@+id/button_update"
android:layout_toEndOf="@+id/button_update"
android:layout_marginRight="15dp"
android:singleLine="true"
android:gravity="center_horizontal" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_year"
android:layout_below="@+id/editText_name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColorHint="#ffffff"
android:layout_alignLeft="@+id/editText_name"
android:layout_alignStart="@+id/editText_name"
android:layout_marginRight="15dp"
android:singleLine="true"
android:gravity="center_horizontal"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_genres"
android:layout_below="@+id/editText_year"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColorHint="#ffffff"
android:layout_alignLeft="@+id/editText_year"
android:layout_alignStart="@+id/editText_year"
android:layout_marginRight="15dp"
android:singleLine="true"
android:gravity="center_horizontal"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_runtime"
android:layout_below="@+id/editText_genres"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColorHint="#ffffff"
android:layout_alignLeft="@+id/editText_genres"
android:layout_alignStart="@+id/editText_genres"
android:layout_marginRight="15dp"
android:singleLine="true"
android:gravity="center_horizontal"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_about"
android:layout_below="@+id/editText_runtime"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColorHint="#ffffff"
android:layout_alignLeft="@+id/editText_runtime"
android:layout_alignStart="@+id/editText_runtime"
android:layout_marginRight="15dp"
android:singleLine="true"
android:gravity="center_horizontal"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_rating"
android:layout_below="@+id/editText_about"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColorHint="#ffffff"
android:layout_alignLeft="@+id/editText_about"
android:layout_alignStart="@+id/editText_about"
android:layout_marginRight="15dp"
android:singleLine="true"
android:gravity="center_horizontal"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText_id"
android:layout_below="@+id/editText_rating"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColorHint="#ffffff"
android:layout_alignLeft="@+id/editText_rating"
android:layout_alignStart="@+id/editText_rating"
android:layout_marginRight="15dp"
android:singleLine="true"
android:gravity="center_horizontal"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ĮKELTI"
android:id="@+id/button_add"
android:background="#ffcb4e"
android:layout_below="@+id/editText_rating"
android:layout_marginTop="60dp"
android:layout_marginLeft="70dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ŽIŪRĖTI"
android:id="@+id/button_viewAll"
android:background="#ffcb4e"
android:layout_alignTop="@+id/button_add"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="70dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ATNAUJINTI"
android:id="@+id/button_update"
android:background="#ffcb4e"
android:layout_marginTop="40dp"
android:layout_below="@+id/button_add"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="70dp"
android:padding="5dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ištrinti"
android:id="@+id/button_delete"
android:layout_alignBottom="@+id/button_update"
android:layout_alignRight="@+id/button_viewAll"
android:layout_alignEnd="@+id/button_viewAll"
android:padding="5dp"
android:background="#ffcb4e" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Pavadinimas:"
android:id="@+id/textView_name"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:layout_above="@+id/editText_year" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Metai:"
android:id="@+id/textView_year"
android:layout_alignLeft="@+id/textView_name"
android:layout_alignStart="@+id/textView_name"
android:layout_below="@+id/textView_name"
android:layout_alignBottom="@+id/editText_year" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Žanras:"
android:id="@+id/textView_genres"
android:layout_alignLeft="@+id/textView_year"
android:layout_alignStart="@+id/textView_year"
android:layout_alignBottom="@+id/editText_genres"
android:layout_below="@+id/textView_year" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Trukmė:"
android:id="@+id/textView_runtime"
android:layout_below="@+id/textView_genres"
android:layout_alignLeft="@+id/textView_genres"
android:layout_alignStart="@+id/textView_genres"
android:layout_alignBottom="@+id/editText_runtime" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Aprašymas:"
android:id="@+id/textView_about"
android:layout_alignLeft="@+id/textView_runtime"
android:layout_alignStart="@+id/textView_runtime"
android:layout_below="@+id/textView_runtime"
android:layout_alignBottom="@+id/editText_about" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Įvertinimas:"
android:id="@+id/textView_rating"
android:layout_below="@+id/textView_about"
android:layout_alignLeft="@+id/textView_about"
android:layout_alignStart="@+id/textView_about"
android:layout_alignBottom="@+id/editText_rating" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="ID:"
android:id="@+id/textView_id"
android:layout_below="@+id/textView_rating"
android:layout_alignLeft="@+id/textView_rating"
android:layout_alignStart="@+id/textView_rating"
android:layout_alignBottom="@+id/editText_id" />
</RelativeLayout>
</ScrollView>`
This is how it looks in emulator. It is hard to see, but the view is cut right after the last button.
Upvotes: 1
Views: 2068
Reputation: 703
Add a blank view as last item under scroll view. Example:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="56dp"/>
</LinearLayout>
</ScrollView>
Upvotes: 0
Reputation: 1316
The structure of your layout is wrong. I would do something like this:
<ScrollView>
//Layout father
<LinearLayout orientation="vertical"...>
//Automatically aligned one under the other
<EditText/>//No layout_below, no layout_align
<EditText/>
<EditText/>
<EditText/>...
<LinearLayout orientation="horizontal"...>
//If the width is 0 and weight 1, each button will occupy half of the screen
<Button android:layout_width="0dp"
android:layout_weight="1".../>
<Button android:layout_width="0dp"
android:layout_weight="1".../>
</LinearLayout>
//And so on...
</LinearLayout>
</ScrollView>
Good luck!
Upvotes: 1
Reputation: 3118
Try putting this in ScrollView
android:fillViewport="true"
Here is a nice reference: Romain Guy's trick with ScrollView
Upvotes: 1