Reputation: 810
I am trying to use a scrollview in a framelayout. The scrollview should be displayed just in the downer half of the display.
At the moment the positioning is right:
http://www.gtv-handball.de/Unbenannt.png
As you can see, the right areas are scollable or not. But the problem is, that the upper part can't be clicked anymore, cause the scrollview is over this part.
To display the scrollview in the downer half, I put some padding on it:
scrollviwe = (ScrollView)findViewById(R.id.linlayout);
scrollview.setPadding(0, 175, 0, 0);
So I didn't find any way to get this displayed with the padding option.
I think, there is no way to get around setting a margin for the scrollview, but how do I so?
Here is the complete, but shortened XML code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/framelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left" >
<ImageView
android:id="@+id/coverimg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:maxHeight="100dp"
android:minHeight="130dp"
android:minWidth="130dp"
android:src="@drawable/cover_img" />
</FrameLayout>
<ScrollView
android:id="@+id/linlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linlayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/teilen"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_blue"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="Teilen"
android:layout_margin="4dp"
android:layout_weight="1" />
<Button
android:id="@+id/kaufen"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_blue"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="Kaufen"
android:layout_margin="4dp"
android:layout_weight="1"/>
<Button
android:id="@+id/youtube"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_blue"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="YouTube"
android:layout_margin="4dp"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Zuletzt gehört:" />
</LinearLayout>
</ScrollView>
</FrameLayout>
Upvotes: 2
Views: 5579
Reputation: 1399
I would suggest that you wrap a linear layout. Since its easier to manage how much space it takes on the screen using weights.
you can try this out.
<?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"
android:weightSum="1" >
<LinearLayout
android:id="@+id/framelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_weight="0.5"
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:id="@+id/coverimg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:maxHeight="100dp"
android:minHeight="130dp"
android:minWidth="130dp"
android:src="@drawable/ic_launcher"
android:layout_weight="0.5" />
<LinearLayout android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Text"/>
<!-- Add other views -->
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/linlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5" >
<LinearLayout
android:id="@+id/linlayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/teilen"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="Teilen" />
<Button
android:id="@+id/kaufen"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="Kaufen" />
<Button
android:id="@+id/youtube"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="YouTube" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Zuletzt gehört:" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Upvotes: 0
Reputation: 7100
Have you tried looking into using a RelativeLayout? If I understand your goals correctly, it might be easier to manage all the different views on the screen, as you can align views relative to each other or the borders of the screen. It can also be used in a similar fashion to FrameLayouts to overlay views on top of one another.
Upvotes: 1
Reputation: 274
Try setting margin or padding to the View outside the ScrollView. In this case it would be FrameLayout.
Upvotes: 0