Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- backgroundTint
- PostgreSQL
- viewmodel
- RestAPI
- addTextChangedListner
- DialogFragment
- cocoapod
- Dialog
- editText
- calendar
- android
- springboot
- Button
- prolificinteractive/material-calendarview
- livedata
- podinit
- 리눅스
Archives
- Today
- Total
코코딩딩
[안드로이드/android] editText 위에 겹쳐진 버튼 본문
editText 위에 버튼을 올려서 구현하려면 다음과 같다.

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp"
tools:ignore="MissingConstraints">
<GridLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:columnCount="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="center">
<EditText
android:layout_width="match_parent"
android:layout_height="46dp"
android:textSize="16sp"
android:layout_column="1"
android:hint="editText"/>
</LinearLayout>
<LinearLayout
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="right"
android:layout_marginRight="2dp">
<Button
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_column="1"
android:text="버튼1"
android:layout_gravity="right"
android:layout_marginRight="10dp"/>
<Button
android:layout_width="70dp"
android:layout_height="40dp"
android:text="버튼2"
android:layout_column="1"
android:layout_gravity="right"/>
</LinearLayout>
</GridLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
위와 같이 구성을 했을 경우 버튼 2의 visibility를 "gone"으로 설정해주면 아래와 같이 버튼 1이 오른쪽으로 붙는다.

'일단기록 > 간단기록' 카테고리의 다른 글
[JAVA] 시간 계산 하기 (0) | 2022.05.20 |
---|---|
[안드로이드/android] activity 화면 전환 데이터 주고받기 (intent) (0) | 2022.05.19 |
[안드로이드/android] 비밀번호,핸드폰번호 정규식 (0) | 2022.05.11 |
[JAVA] 10초 마다 반복 실행하기 (0) | 2022.05.10 |
[자료구조] json 실수한것 (0) | 2022.05.09 |