Android 사용 으로 위 챗 채 팅 입력 상자 기능 구현

LayerDrawable <layer-list> 라벨 은 LayerDrawable 을 설정 합 니 다.차원 이 있 는 Drawable 중첩 효과 입 니 다.는 여러 개의라벨 을 포함 할 수 있 습 니 다.
 각각은 Drawable 을 대표 합 니 다.left,right,top,bottom 을 통 해 좌우 상하 의 오프셋 을 설정 할 수 있 습 니 다.은 그림 을 사용 할 수도 있 고 shape 일 수도 있 습 니 다.
  우 리 는 위 챗 을 실현 하 는 채 팅 입력 상 자 를 모방 합 니 다.
 녹색 배경 설정 하기:

 <?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
   <shape android:shape="rectangle">
    <solid android:color="@android:color/holo_green_light" />
   </shape>
  </item>
 </layer-list>

 흰색 을 한 겹 더 겹 쳐 옆 면 녹색 라인 의 높이 를 남 깁 니 다.

 <?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
   <shape android:shape="rectangle">
    <solid android:color="@android:color/holo_green_light" />
   </shape>
  </item>
  <item android:bottom="8dp">
   <shape android:shape="rectangle">
    <solid android:color="@android:color/white" />
   </shape>
  </item>
 </layer-list>

흰색 을 한 층 더 깔 고 설 치 된 배경 을 덮 고 바닥 과 측면의 선 을 남 깁 니 다.중간의 한 층 은 사실은 양쪽 의 녹색 선 틀 의 높이 를 남기 기 위해 서 입 니 다. 

<?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
   <shape android:shape="rectangle">
    <solid android:color="@android:color/holo_green_light" />
   </shape>
  </item>
  <item android:bottom="8dp">
   <shape android:shape="rectangle">
    <solid android:color="@android:color/white" />
   </shape>
  </item>
  <item
   android:bottom="1dp"
   android:left="1dp"
   android:right="1dp"
   android:shape="rectangle">
   <shape>
    <solid android:color="@android:color/white" />
   </shape>
  </item>
 </layer-list>
 
위 에서 말 한 것 은 소 편 이 소개 한 안 드 로 이 드 가를 사용 하여 위 챗 채 팅 입력 상 자 를 실현 하 는 것 입 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남 겨 주세요.소 편 은 제때에 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!

좋은 웹페이지 즐겨찾기