https://newsapi.org/s/south-korea-news-api
South Korea News API - Live top headlines from South Korea
Get live top and breaking news headlines from South Korea with our JSON API. Live example This example demonstrates the HTTP request to make, and the JSON response you will receive, when you use the News API to get live headlines from South Korea. Top head
newsapi.org
Json데이터를 사용하기 위해 Json형식으로 되어있는 News API를 사용하겠다
https://developer.android.com/guide/topics/ui/layout/cardview?hl=ko
카드 기반 레이아웃 만들기 | Android 개발자 | Android Developers
카드 기반 레이아웃 만들기 앱에서는 데이터를 비슷한 스타일의 컨테이너에 표시해야 할 때가 많습니다. 이러한 컨테이너는 각 항목의 정보를 보관하기 위해 목록에서 자주 사용됩니다. 시스템
developer.android.com
dependencies {
implementation "androidx.cardview:cardview:1.0.0"
}
CardView를 사용하기 위해 build.gradle(Module:app) 에 종속성 먼저 추가한다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="250dp"
android:orientation="vertical"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="12dp">
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="12dp"
card_view:cardCornerRadius="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="180dp">
<ImageView
android:id="@+id/imageView_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:src="@drawable/ic_launcher_foreground"/>
<TextView
android:id="@+id/textView_title"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="text_area"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textSize="20sp"
android:gravity="center"
android:background="#70000000"
android:textColor="#ffffff"
android:textStyle="bold"
android:layout_alignParentBottom="true">
</TextView>
</RelativeLayout>
<TextView
android:id="@+id/textView_content"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="text_area"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textSize="12sp"
android:ellipsize="end">
</TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
기존의 RelativeLayout 전체를 CardView안에 넣어준다
( 나는 만들 레이아웃 상 LinearLayout도 추가했다 )
android:maxLines="2"
android:ellipsize="end"
본문의 글자가 많아지면 ... 처리되게 TextView에 maxLines를 설정 ( ellipsize는 저번에 함 )
dependencies {
implementation 'com.facebook.fresco:fresco:2.6.0'
}
dependencies {
implementation 'com.android.volley:volley:1.1.1'
}
'Android' 카테고리의 다른 글
[Android/Java] JsonAPI 데이터 화면에 출력하기 (0) | 2022.01.14 |
---|---|
[Android/Java] Volley + JsonAPI사용 (0) | 2022.01.11 |
[Android/Java] RecyclerView & Adapter 사용 (0) | 2022.01.04 |
[Android/Java] Design lib (0) | 2022.01.04 |
[Android/Java] Intent 사용 (0) | 2022.01.04 |