마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Listview에서 일부만 글자 크기 조절 가능한가요?

0 추천

채팅방에 옆에 작게 시간이 뜨게하려고 하는데여

ListView와 Arrayadapter을 이용해서 채팅창을 구현 중인데  listview에  user, time, message 세가지가 들어가요

chat_user = (String) ((DataSnapshot) i.next()).getValue();
chat_msg = (String) ((DataSnapshot) i.next()).getValue();
chat_time = (String) ((DataSnapshot) i.next()).getValue();

arrayAdapter.add(chat_time + chat_user + " : " + chat_msg);

chat_time만 글자 크기를 줄이고 싶은데 가능할까요?

arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
simple_list_item_2를 이용해야하나여 ?ㅇㅅㅇ
준쥐 (120 포인트) 님이 2017년 8월 18일 질문

2개의 답변

0 추천
simple_list_item_1 xml에서 chat_time의 글자 크기를 줄이시면 됩니다 :)
minor (13,710 포인트) 님이 2017년 8월 18일 답변
0 추천
둘 중 편한 방식 사용하세요.

1. ArrayAdapter 를 상속받은 custom ArrayAdapter를 만들어서 구현

http://www.framentos.com/en/android-tutorial/2012/07/16/listview-in-android-using-custom-listadapter-and-viewcache/

2. ArrayAdapter<String> 를  ArrayAdapter<Spanned> 로  변경하고,  Html.formHtml로 chat_time 엔 별도 폰트 사이즈를 html 태그로 지정

ex)
arrayAdapter.add(Html.formHtml("<font size = '11'>" + chat_time  + "</font>" + chat_user + " : " + chat_msg));

http://gdrcoon.tistory.com/479
익명사용자 님이 2017년 8월 18일 답변
...