Мне нужно разделить макет на две части:
- верхняя часть должна быть без ScrollView (чтобы рисовать горизонтальные и вертикальные линии. У меня проблемы с рисованием вертикальных линий, когда у полного макета есть ScrollView)
- нижняя часть должна быть с ScrollView (для прокрутки разных элементов)
Эта картинка поясняет, как она должна выглядеть:
Мой файл макета выглядит так:
<?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).
Я пробовал разные вещи без успеха:
- определил 1
ScrollView
по всей странице и попытался ограничить ее высоту -> вертикальные линии не могут быть нарисованы - изменил
layout_height
наwrap_content
-> без изменений. Я также определил его какcom.unitnode.Drawing
, но приложение закрылось из-за методаonSizeChanged( )
(ширина и высота должны быть > 0) - Я попытался вставить элемент ScrollView после представления чертежа. И добавил для этого еще один Framelayout -> не может справиться с этим
Если вам нужен код Java, пожалуйста, дайте мне знать.
Пожалуйста, помогите мне изменить мой код, чтобы макет состоял из двух частей (показано на картинке)
РЕДАКТИРОВАТЬ: я изменил свой файл xml на это (использовал FrameLayout
из-за правильного форматирования):
<?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>
onTouch( )
моего классаDrawing
больше не вызывается. Поэтому я больше не могу рисовать с помощью ScrollView. Проблема определенно в ScrollView, потому что, когда я комментирую ScrollView из моего xml-файла, все работает отлично. ПочемуsetOnTouchListener
больше не работает и как правильно добавить ScrollView? 23.09.2014