JavaRush /Курсы /Курс "Программирование под Андроид" /Внутренний и внешний отступ

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

Курс "Программирование под Андроид"
2 уровень , 10 лекция
Открыта

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

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

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

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

Комментарии (88)
ЧТОБЫ ПОСМОТРЕТЬ ВСЕ КОММЕНТАРИИ ИЛИ ОСТАВИТЬ КОММЕНТАРИЙ,
ПЕРЕЙДИТЕ В ПОЛНУЮ ВЕРСИЮ
Vladimir2020 Уровень 0
25 апреля 2022
Кстати кто в 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"
Андрей Уровень 37
23 декабря 2021

<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
После java довольно просто ) во всяком случаи на данный момент ) вот ниже сделал пол страницы из плей маркета как тест, так как у них там вроде много элементов ) дальше не получается так как в визулизаторе не хватает места ))) но суть вроде уловил )
15 ноября 2021
Dmytrii Уровень 40
18 сентября 2024
а где вы картинки берете?) как их указывать? PS а где тут Java то используется? Чистый xml же
Igor Уровень 18
30 октября 2021
Маргин и Паддинг здесь были 😆
Anonymous #2508202 Уровень 1
26 января 2021
Дядя Саша сам сделал
Руслан Асаев Уровень 14
19 января 2021
Good modul
hidden #1375539 Уровень 24
14 декабря 2020
<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

android:paddingBottom="8dp"
надо

android:paddingBottom="16dp"
3 декабря 2020
<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
Добавь android:layout_marginTop в ImageView
Ksenia Уровень 24
13 декабря 2020
если еще актуально в ImageView стоит marginBottom
Ksenia Уровень 24
13 декабря 2020
это только добавит еще одну белую полосу сверху
Anonymous #2482692 Уровень 1
13 декабря 2020
Нет, нужно лишь уравнять
Staсy Уровень 10
13 декабря 2020
Уберите

android:layout_marginBottom="8dp"
из ImageView
hidden #1375539 Уровень 24
14 декабря 2020
я так сделал https://prnt.sc/w2fkq4
RetroGuy Уровень 1
28 ноября 2020
Оказывается, для экономии строчек кода, можно сначала указывать общий отступ для элемента, а потом перезаписать интересующий на другое значение: <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>