Vik0809
Vik0809

Reputation: 379

Can't add scrollView to layout

I have to split my layout in two parts:

  1. the upper part shall be without ScrollView (in order to draw horizontal and vertical lines. I have got problems to draw vertical Lines, when the complete Layout have got a ScrollView)
  2. the lower part shall be with ScrollView (in order to scroll through different Elements)

This picture shall explain, how it should look like: enter image description here

My layoutfile looks like that:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawingLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >

<com.unitnode.Drawing
    android:id="@+id/drawingView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<ImageButton
    android:id="@+id/eraseButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/rubber" />

<ImageButton
    android:id="@+id/undoButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/undo" />

<ImageButton
    android:id="@+id/neuerZeichenButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/newbutton" />

<ImageButton
    android:id="@+id/saveZeichenView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/savebutton" />

<View
    android:id="@+id/linie1"
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#000000" />

<TextView
    android:id="@+id/hintergrundfarbeFullZeichenView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hintergrundfarbe" />

<Button
    android:id="@+id/hintergrundfarbeFullButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/schwarzbuttonshape" />

<Button
    android:id="@+id/hintergrundfarbeFullButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/roterbuttonshape" />

<Button
    android:id="@+id/hintergrundfarbeFullButton3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/gelberbuttonshape" />

<Button
    android:id="@+id/hintergrundfarbeFullButton4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/weiserbuttonshape" />

<ImageButton
    android:id="@+id/hintergrundfarbeFullButton5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/farbpallete" />

<View
    android:id="@+id/linie2"
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#000000" />

<TextView
    android:id="@+id/strichfarbeFullText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Strichfarbe" />

<Button
    android:id="@+id/strichfarbeFullButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/schwarzbuttonshape" />

<Button
    android:id="@+id/strichfarbeFullButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/roterbuttonshape" />

<Button
    android:id="@+id/strichfarbeFullButton3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/gelberbuttonshape" />

<Button
    android:id="@+id/strichfarbeFullButton4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/weiserbuttonshape" />

<ImageButton
    android:id="@+id/strichfarbeFullButton5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/farbpallete" />

<View
    android:id="@+id/linie3"
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#000000" />

<TextView
    android:id="@+id/strichdickeTextFull"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Strichdicke" />

<SeekBar
    android:id="@+id/strokeSeekbarFull"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/strichdickeTextMinFull"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0dp" />

<View
    android:id="@+id/linie4"
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#000000" />

<TextView
    android:id="@+id/opacityText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Durchsichtigkeit: " />

<TextView
    android:id="@+id/opacityMinText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0% " />

<SeekBar
    android:id="@+id/opacitySeekbarFull"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<CheckBox
    android:id="@+id/unschaerfeFilterCheckBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Unschärfefilter AN/AUS"
    android:textSize="12sp" />

<TextView
    android:id="@+id/radiusTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Radius:" />

<TextView
    android:id="@+id/radiusMinTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="1dp" />

<SeekBar
    android:id="@+id/unschaerfeSeekbar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<RadioButton
    android:id="@+id/unschaerfeCheckBox1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Inner"
    android:textSize="10sp" />

<RadioButton
    android:id="@+id/unschaerfeCheckBox2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Normal"
    android:textSize="10sp" />

<RadioButton
    android:id="@+id/unschaerfeCheckBox3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Outer"
    android:textSize="10sp" />

<RadioButton
    android:id="@+id/unschaerfeCheckBox4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Solid"
    android:textSize="10sp" />

<TextView
    android:id="@+id/formenText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Formen: " />

<ImageButton
    android:id="@+id/kreisFull"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/kreis" />

the Element com.unitnode.Drawing is my Drawing View (the upper part).

I tried different things without success:

  1. defined 1 ScrollView over whole page and tried to limit the height of it -> vertical lines can't be drawn
  2. changed layout_height to wrap_content -> no change. I defined it to com.unitnode.Drawing too, but the app shut down because of onSizeChanged( ) method (width and height must > 0)
  3. I tried to insert a ScrollView element after the drawing View. And added for this another Framelayout -> can't handle that

If you need Java code, please let me know.

Please help me to change my code, so that the layout consists of two part (shown in picture)

EDIT: I changed my xml file to this (used FrameLayout because of correct formatting):

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawingLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/drawingLayout2"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <com.unitnode.Drawing
            android:id="@+id/drawingView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>

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

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

            <ImageButton
                android:id="@+id/eraseButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/rubber" />

            <ImageButton
                android:id="@+id/undoButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/undo" />

            <ImageButton
                android:id="@+id/neuerZeichenButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/newbutton" />

            <ImageButton
                android:id="@+id/saveZeichenView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/savebutton" />

            <View
                android:id="@+id/linie1"
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:background="#000000" />

            <TextView
                android:id="@+id/hintergrundfarbeFullZeichenView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hintergrundfarbe" />

            <Button
                android:id="@+id/hintergrundfarbeFullButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/schwarzbuttonshape" />

            <Button
                android:id="@+id/hintergrundfarbeFullButton2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/roterbuttonshape" />

            <Button
                android:id="@+id/hintergrundfarbeFullButton3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/gelberbuttonshape" />

            <Button
                android:id="@+id/hintergrundfarbeFullButton4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/weiserbuttonshape" />

            <ImageButton
                android:id="@+id/hintergrundfarbeFullButton5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/farbpallete" />

            <View
                android:id="@+id/linie2"
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:background="#000000" />

            <TextView
                android:id="@+id/strichfarbeFullText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Strichfarbe" />

            <Button
                android:id="@+id/strichfarbeFullButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/schwarzbuttonshape" />

            <Button
                android:id="@+id/strichfarbeFullButton2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/roterbuttonshape" />

            <Button
                android:id="@+id/strichfarbeFullButton3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/gelberbuttonshape" />

            <Button
                android:id="@+id/strichfarbeFullButton4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/weiserbuttonshape" />

            <ImageButton
                android:id="@+id/strichfarbeFullButton5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/farbpallete" />

            <View
                android:id="@+id/linie3"
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:background="#000000" />

            <TextView
                android:id="@+id/strichdickeTextFull"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Strichdicke" />

            <SeekBar
                android:id="@+id/strokeSeekbarFull"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/strichdickeTextMinFull"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0dp" />

            <View
                android:id="@+id/linie4"
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:background="#000000" />

            <TextView
                android:id="@+id/opacityText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Durchsichtigkeit: " />

            <TextView
                android:id="@+id/opacityMinText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0% " />

            <SeekBar
                android:id="@+id/opacitySeekbarFull"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <CheckBox
                android:id="@+id/unschaerfeFilterCheckBox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Unschärfefilter AN/AUS"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/radiusTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Radius:" />

            <TextView
                android:id="@+id/radiusMinTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1dp" />

            <SeekBar
                android:id="@+id/unschaerfeSeekbar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <RadioButton
                android:id="@+id/unschaerfeCheckBox1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Inner"
                android:textSize="10sp" />

            <RadioButton
                android:id="@+id/unschaerfeCheckBox2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Normal"
                android:textSize="10sp" />

            <RadioButton
                android:id="@+id/unschaerfeCheckBox3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Outer"
                android:textSize="10sp" />

            <RadioButton
                android:id="@+id/unschaerfeCheckBox4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Solid"
                android:textSize="10sp" />

            <TextView
                android:id="@+id/formenText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Formen: " />

            <ImageButton
                android:id="@+id/kreisFull"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/kreis" />
        </FrameLayout>
   </ScrollView>

</FrameLayout>

Upvotes: 2

Views: 392

Answers (2)

Vik0809
Vik0809

Reputation: 379

It seems, that the ScrollView is located on Top of the whole underlaying FrameLayout. That's the reason, because I can't draw anything. When I set the Visibilty of the ScrollView to invisible than I am able to draw again. But I can't see the elements anymore certainly.

Is there an other way than changing the visibility? Is it possible to bring the underlaying FrameLayout to the front and how could I achieve that?

Upvotes: 0

Suneel Prakash
Suneel Prakash

Reputation: 389

You should try your layout as below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawingLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/drawingContainerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

       <!-- Need to add your drawing view-->
    </RelativeLayout>

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" >
            <!-- Bottom views that are scrollable -->



        </LinearLayout>
    </ScrollView>

</LinearLayout>

Upvotes: 1

Related Questions