Nano Hash - криптовалюты, майнинг, программирование

Не могу добавить scrollView в макет

Мне нужно разделить макет на две части:

  1. верхняя часть должна быть без ScrollView (чтобы рисовать горизонтальные и вертикальные линии. У меня проблемы с рисованием вертикальных линий, когда у полного макета есть ScrollView)
  2. нижняя часть должна быть с 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. определил 1 ScrollView по всей странице и попытался ограничить ее высоту -> вертикальные линии не могут быть нарисованы
  2. изменил layout_height на wrap_content -> без изменений. Я также определил его как com.unitnode.Drawing, но приложение закрылось из-за метода onSizeChanged( ) (ширина и высота должны быть > 0)
  3. Я попытался вставить элемент 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>


  • Я думаю, что лучший способ - установить все компоненты, которые должны отображаться на верхнем дисплее внутри контейнера (например, LinearLayout), а также нижние элементы в другом. 22.09.2014

Ответы:


1

Вы должны попробовать свой макет, как показано ниже:

<?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>
22.09.2014
  • зависит ли это от того, какой макет я использую? Могу ли я использовать FrameLayout вместо LinearLayout или RelativeLayout? 22.09.2014
  • да, вы можете использовать FrameLayout вместо линейных или относительных макетов. Но для нижнего макета в прокрутке в вашем случае предпочтительнее линейный 23.09.2014
  • большое спасибо за ответ и комментарии. Но когда я использую ScrollView, метод onTouch( ) моего класса Drawing больше не вызывается. Поэтому я больше не могу рисовать с помощью ScrollView. Проблема определенно в ScrollView, потому что, когда я комментирую ScrollView из моего xml-файла, все работает отлично. Почему setOnTouchListener больше не работает и как правильно добавить ScrollView? 23.09.2014
  • Опубликуйте свой измененный макет, чтобы мы могли помочь 23.09.2014

  • 2

    Кажется, что ScrollView расположен поверх всего нижележащего FrameLayout. Это потому, что я ничего не умею рисовать. Когда я устанавливаю видимость ScrollView на invisible, я снова могу рисовать. Но я больше не могу видеть элементы, конечно.

    Есть ли другой способ, кроме изменения видимости? Можно ли вывести лежащий в основе FrameLayout на передний план и как я могу этого добиться?

    25.09.2014
    Новые материалы

    Кластеризация: более глубокий взгляд
    Кластеризация — это метод обучения без учителя, в котором мы пытаемся найти группы в наборе данных на основе некоторых известных или неизвестных свойств, которые могут существовать. Независимо от..

    Как написать эффективное резюме
    Предложения по дизайну и макету, чтобы представить себя профессионально Вам не позвонили на собеседование после того, как вы несколько раз подали заявку на работу своей мечты? У вас может..

    Частный метод Python: улучшение инкапсуляции и безопасности
    Введение Python — универсальный и мощный язык программирования, известный своей простотой и удобством использования. Одной из ключевых особенностей, отличающих Python от других языков, является..

    Как я автоматизирую тестирование с помощью Jest
    Шутка для победы, когда дело касается автоматизации тестирования Одной очень важной частью разработки программного обеспечения является автоматизация тестирования, поскольку она создает..

    Работа с векторными символическими архитектурами, часть 4 (искусственный интеллект)
    Hyperseed: неконтролируемое обучение с векторными символическими архитектурами (arXiv) Автор: Евгений Осипов , Сачин Кахавала , Диланта Хапутантри , Тимал Кемпития , Дасвин Де Сильва ,..

    Понимание расстояния Вассерштейна: мощная метрика в машинном обучении
    В обширной области машинного обучения часто возникает необходимость сравнивать и измерять различия между распределениями вероятностей. Традиционные метрики расстояния, такие как евклидово..

    Обеспечение масштабируемости LLM: облачный анализ с помощью AWS Fargate и Copilot
    В динамичной области искусственного интеллекта все большее распространение получают модели больших языков (LLM). Они жизненно важны для различных приложений, таких как интеллектуальные..