Внутренний и внешний отступ

Открыта

Ссылка на визуализатор XML

В этом уроке мы использовали такие слова:

Внутренний отступ padding
Внешний отступ margin

Их определения можно найти в Словаре терминов.

Комментарии (88)
  • популярные
  • новые
  • старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
Vladimir2020
Уровень 0
25 апреля 2022, 00:53
Кстати кто в Android Studio делает не забывайте добавить эти строки в разделе res/values/strings.xml <resources> <string name="app_name">JavaRushThankyou</string> <string name="ocean_vacation">ocean_vacation</string> <string name="ocean">ocean</string> <string name="string_ocean"/> <string name="You_are_invited">Youre invited!</string> <string name="Bonfire">Bonfire at the beach</string> </resources> И раздел color.xml добавить строчку с <color name="green">#009688</color> Плюс еще надо в ImageView добавить android:contentDescription="@string/string_ocean"
АндрейРаботает в КАМАЗ
23 декабря 2021, 13:14
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:src="@drawable/ocean"
        android:layout_width="match_parent"
        android:layout_height="0dp"
       	android:padding="18dp"
        android:layout_weight="1"
        android:scaleType="centerCrop"
         />

    <TextView
        android:text="You're invited!"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:paddingTop="16dp"
        android:paddingLeft="18dp"
        android:paddingBottom="8dp"
        android:textSize="45sp"
        android:background="#009688"/>

    <TextView
        android:text="Bonfire at the beach"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="18dp"
        android:paddingBottom="8dp"
        android:textColor="@android:color/white"
        android:textSize="24sp"
        android:background="#009688"/>

</LinearLayout>
15 ноября 2021, 23:39
После java довольно просто ) во всяком случаи на данный момент ) вот ниже сделал пол страницы из плей маркета как тест, так как у них там вроде много элементов ) дальше не получается так как в визулизаторе не хватает места ))) но суть вроде уловил )
15 ноября 2021, 23:37
Dmytrii
Уровень 70
18 сентября 2024, 10:30
а где вы картинки берете?) как их указывать? PS а где тут Java то используется? Чистый xml же
Igor
Уровень 2
30 октября 2021, 02:18
Маргин и Паддинг здесь были 😆
Anonymous #2508202
Уровень 1
26 января 2021, 10:16
Дядя Саша сам сделал
Руслан Асаев
Уровень 14
19 января 2021, 17:52
Good modul
hidden #1375539
Уровень 24
14 декабря 2020, 13:36
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#009688" android:orientation="vertical"> <ImageView android:src="@drawable/ocean" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:scaleType="centerCrop" /> <TextView android:text="You're invited!" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@android:color/white" android:textSize="45sp" android:paddingTop="16dp" android:paddingLeft="16dp" android:background="#009688"/> <TextView android:text="Bonfire at the beach" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@android:color/white" android:textSize="24sp" android:paddingLeft="16dp" android:paddingTop="8dp" android:paddingBottom="8dp" android:background="#009688"/> </LinearLayout>
Александр
Уровень 24
18 февраля 2021, 13:26
android:paddingBottom="8dp"
надо
android:paddingBottom="16dp"
Александр ДовгальЛичный водитель в МО РФ
3 декабря 2020, 00:45
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:src="@drawable/ocean" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:scaleType="centerCrop" android:layout_marginBottom="8dp"/> <TextView android:text="You're invited!" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@android:color/white" android:textSize="45sp" android:background="#FF444C" android:paddingLeft="16dp" android:paddingTop="16dp"/> <TextView android:text="Bonfire at the beach" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@android:color/white" android:textSize="24sp" android:background="#009555" android:paddingTop="8dp" android:paddingLeft="16dp" android:paddingBottom="16dp"/> </LinearLayout> Как убрать белую полосу?
Anonymous #2482692
Уровень 1
13 декабря 2020, 13:18
Добавь android:layout_marginTop в ImageView
Ksenia
Уровень 24
13 декабря 2020, 13:19
если еще актуально в ImageView стоит marginBottom
Ksenia
Уровень 24
13 декабря 2020, 13:21
это только добавит еще одну белую полосу сверху
Anonymous #2482692
Уровень 1
13 декабря 2020, 13:31
Нет, нужно лишь уравнять
StaсyJava Developer в SoftClub
13 декабря 2020, 18:09
Уберите
android:layout_marginBottom="8dp"
из ImageView
hidden #1375539
Уровень 24
14 декабря 2020, 13:37
я так сделал https://prnt.sc/w2fkq4
RetroGuy
Уровень 1
28 ноября 2020, 11:14
Оказывается, для экономии строчек кода, можно сначала указывать общий отступ для элемента, а потом перезаписать интересующий на другое значение: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:src="@drawable/ocean" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:scaleType="centerCrop"/> <TextView android:text="You're invited!" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="16dp" android:paddingBottom="4dp" android:textColor="@android:color/white" android:textSize="45sp" android:background="#009688" /> <TextView android:text="Bonfire at the beach" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@android:color/white" android:textSize="24sp" android:background="#009688" android:padding="16dp" android:paddingTop="4dp"/> </LinearLayout>