스팀 앱 개발기 #56 - 포스트 리스트를 구성할 항목의 레이아웃steemCreated with Sketch.

앞으로 피드나 블로그 화면에서 포스트 리스트를 보여주려고 하는데요. 이 리스트를 구성할 항목의 레이아웃을 위 그림과 같이 구성하고 있습니다. 편의상 이 항목의 이름은 포스트 항목이라고 부르겠습니다. 이번 포스트에서는 이 레이아웃을 만드는 코드를 보여드리고자 합니다.


포스트 항목이 보여줄 내용

  • 포스트 제목
  • 텍스트 내용 앞부분 (1줄)
  • 보상
  • 업보트 수
  • 다운보트 수
  • 저자

XML 코드

이번에는 데이터 바인딩을 적용하지 않았습니다. 포스트 리스트를 구현할 때 이를 적용할 예정입니다.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="8dp">

    <TextView
        android:id="@+id/text_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:textColor="@color/black"
        android:textSize="18sp"
        android:textStyle="bold"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="Title Example" />

    <ImageView
        android:id="@+id/image_thumbnail"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginTop="5dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@id/text_title"
        tools:src="@mipmap/ic_launcher" />

    <TextView
        android:id="@+id/text_content"
        android:layout_width="0dp"
        android:layout_height="24sp"
        android:layout_marginLeft="8dp"
        android:maxLines="1"
        android:text=""
        android:textColor="@color/black"
        android:textSize="18sp"
        app:layout_constraintTop_toTopOf="@id/image_thumbnail"
        app:layout_constraintLeft_toRightOf="@id/image_thumbnail"
        app:layout_constraintRight_toRightOf="parent"
        tools:text="Content example" />

    <TextView
        android:id="@+id/text_rewards"
        android:layout_width="wrap_content"
        android:layout_height="18sp"
        android:layout_marginLeft="8dp"
        android:maxLines="1"
        android:text=""
        android:textColor="@color/black"
        android:textSize="14sp"
        app:layout_constraintBottom_toBottomOf="@id/image_thumbnail"
        app:layout_constraintLeft_toRightOf="@id/image_thumbnail"
        tools:text="$0.00" />

    <TextView
        android:id="@+id/text_upvotes"
        android:layout_width="wrap_content"
        android:layout_height="18sp"
        android:layout_marginLeft="12dp"
        android:maxLines="1"
        android:text=""
        android:textColor="@color/black"
        android:textSize="14sp"
        app:layout_constraintTop_toTopOf="@id/text_rewards"
        app:layout_constraintLeft_toRightOf="@id/text_rewards"
        tools:text="(UP) 123" />

    <TextView
        android:id="@+id/text_downvotes"
        android:layout_width="wrap_content"
        android:layout_height="18sp"
        android:layout_marginLeft="12dp"
        android:maxLines="1"
        android:text=""
        android:textColor="@color/black"
        android:textSize="14sp"
        app:layout_constraintTop_toTopOf="@id/text_rewards"
        app:layout_constraintLeft_toRightOf="@id/text_upvotes"
        tools:text="(DOWN) 0" />

    <TextView
        android:id="@+id/text_account"
        android:layout_width="wrap_content"
        android:layout_height="18sp"
        android:layout_marginLeft="12dp"
        android:maxLines="1"
        android:text=""
        android:textColor="@color/black"
        android:textSize="14sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        tools:text="dorian-mobileapp" />

</androidx.constraintlayout.widget.ConstraintLayout>

GitHub Commit


마치며...

이번에 보여드린 포스트 항목 레이아웃이 최종확정은 물론 아닙니다. 어떻게 보여주는 것이 최선일지는 계속해서 고민이 되더라구요. 개선안을 찾는다면, 추가로 적용할 예정입니다.


지난 스팀 앱 개발기

Sort:  

Upvoted! Thank you for supporting witness @jswit.

 2 years ago 

[광고] STEEM 개발자 커뮤니티에 참여 하시면, 다양한 혜택을 받을 수 있습니다.

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 57839.82
ETH 3132.70
USDT 1.00
SBD 2.43