Reputation: 81
I am trying to get a linear layout with a button at the bottom of the screen. i have a main parent linear layout that holds a scroll view and a linear layout. the scroll view seems to push the linear layout off screen.
i have tried working with all the layouts width/height properties. but everything looks fine, Ive even inspected it with pixel perfect, but it did not show anything useful.
<LinearLayout 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:orientation="vertical"
android:padding="5dp"
>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/image_title"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/pia04980"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/descp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:padding="5dp"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Refresh" />
</LinearLayout>
</LinearLayout>
string descp is very long, this is why the scroll view fill the entire screen and leaves no room for the other linear layout.
Upvotes: 1
Views: 142
Reputation: 38252
Presently, the height of the ScrollView is determined by its contents. You likely instead want it to consume all additional vertical space of its parent, and scroll its contents. In order to do this, set it to:
<ScrollView
android:id="@+id/scrollView1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp" >
Upvotes: 1
Reputation: 39698
Try not limiting the TextView to a single line
<TextView
android:id="@+id/textView3"
android:singleLine="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/descp"
android:textAppearance="?android:attr/textAppearanceSmall" />
Upvotes: 0