powered by simpleCommunicator - 2.0.18     © 2024 Programmizd 02
Map
Форумы / Разработка под мобильные платформы [игнор отключен] [закрыт для гостей] / Android некорректно отрабатывает перенос слов
4 сообщений из 4, страница 1 из 1
Android некорректно отрабатывает перенос слов
    #39982608
vb_sub
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Всем привет, пишу приложение на Kotlin для Android.
Нужно нарисовать макет с 2-мя RecyclerView сначала вертикальный(MainRecycler), потом в каждом элементе еще разворачивается горизонтальный RecyclerView-Rec (см рисунок).
Главное Activity
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/MainRecycler"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>



Элемент MainRecycler
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
<androidx.cardview.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/Card"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    card_view:cardBackgroundColor="#E6E6E6"
    card_view:cardCornerRadius="8dp"
    card_view:cardElevation="8dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
<TextView
    android:id="@+id/NumberText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignStart="@+id/Rec"
    android:textSize="20sp"
    android:textColor="@color/colorAccent"
    android:textStyle="bold"/>
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/Rec"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="5dp"
            android:orientation="horizontal">
        </androidx.recyclerview.widget.RecyclerView>
    </LinearLayout>
</androidx.cardview.widget.CardView>



Макет элемента для разворачивания горизонтально в Recyclerview(Rec)
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginHorizontal="2sp"
    android:layout_marginStart="5sp"
    android:layout_marginEnd="5sp"
    android:orientation="vertical"
    android:background="@drawable/simple_border">
    <TextView
        android:id="@+id/Header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="20sp" />
<View
    android:layout_width="match_parent"
    android:layout_height="10dp"
    android:background="@drawable/line_separator"/>

    <TextView
        android:id="@+id/Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:textSize="20sp"
        android:textStyle="bold"/>

    <TextView
        android:id="@+id/Descr"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="20sp"
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."/>
    <View
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="@drawable/line_separator"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
<TextView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="0.5"
    android:text="Время получения"

    android:textSize="10sp"
    android:layout_marginRight="1dp"/>
        <View
            android:layout_width="10dp"
            android:layout_height="match_parent"
            android:rotation="90"
            android:background="@drawable/line_separator"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="Время готовности"
            android:textSize="10sp"
            android:layout_marginLeft="1dp"/>
    </LinearLayout>
</LinearLayout>



Проблема в том, что по дефолту текст не переносится на новую строку и обрезается.
Единственное решение для переноса многострочного текста, которое я нашел, это присвоение свойства android:width="0dp" для TextView, однако почему то добавляются дикие отступы до и после TextView и сам элемент расплывается по верстке. К сожалению скриншот сделать не могу, потому что никак не получается установить Hyper-V, хотя все необходимые требования по установке соблюдены- и процессор виртуализацию поддерживает и памяти достаточно и система с последними обновлениями. Просто сначала ставится компонент Hyper-v, комп перегружается, продолжает установку и потом откатывает изменения. Поэтому изображение поехавшей версти прикреплю в следующем сообщении. Спасибо.
...
Рейтинг: 0 / 0
Android некорректно отрабатывает перенос слов
    #39982609
vb_sub
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
Android некорректно отрабатывает перенос слов
    #39982622
Фотография wadman
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Не припоминаю таких проблем... Но помню, что там есть атрибут веса и количества строк для textview.
...
Рейтинг: 0 / 0
Android некорректно отрабатывает перенос слов
    #39982656
vb_sub
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
wadman,
перепробовал разные варианты, работает только установка android:width="0dp" у TextView, но происходит следующая ситуация на картинке
...
Рейтинг: 0 / 0
4 сообщений из 4, страница 1 из 1
Форумы / Разработка под мобильные платформы [игнор отключен] [закрыт для гостей] / Android некорректно отрабатывает перенос слов
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали тему (1): Анонимы (1)
Читали форум (1): Анонимы (1)
Пользователи онлайн (9): Анонимы (7), Yandex Bot 6 мин., Bing Bot 9 мин.
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]