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

중복 리니어 레이아웃 배경색상 넣기 질문있습니다.

0 추천

안녕하세요.. ㅔ

 

레이아웃들을 중복하는 법에 있어서 좀 헷갈린 점이 있어서 여러 레이아웃들의 중복된

형태를 공부해 보고 있는 학생입니다.

 

아래와 같이 리니어 레이아웃을 중복해서 첫번째의 경우는 배경을 연두색을 주고, 그안의 리니어레이아웃을

중복으로 생성하고 위젯을 에딧텍스트와 버튼을 사용해서 주려고 하는데..

 

생각했던것보다 제가 하려고 하는게 잘 되지 않아서 이렇게 글을 올렸습니다.

제 코드상의 어느부분이 잘못되어서 이렇게 나오늕건지 궁금합니다 ㅠ

 

그리고 Match_content 같은 경우에는 너비라던지 높이를 끝까지 다 주는것이고

wrap_content같은 경우에는 임의로 주는걸로 알고 있는데.. 아래의 사진과 같이 하려면

width값은 match로 주고, height값은 wrap으로 준다음에 패딩을 넣는 방법밖에는 없는건가요 ㅠㅠ ?

 

아래와 같이 어떻게 예쁘게 만든는지 방법을 모르겠어요 ㅠ ㅠ

Linear.PNG

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#1fd703"
    android:orientation="vertical"
    tools:context="ex.project3.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#ff0014">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"

            />

        <Button
            android:layout_width="match_parent"
            android:layout_weight="1"
            android:text="버튼"
            android:layout_height="wrap_content"
            />
    </LinearLayout>


</LinearLayout>

[

Kind카인드 (3,600 포인트) 님이 2016년 10월 16일 질문
Match_content -> match_content
wrap_content: 말 그대로 컨텐트의 사이즈 만큼 레이아웃이 감싸주는 겁니다. 님 질문에 어떻게 패딩을 넣는지 알고 계시는 걸 보니 이미 답을 알고 계시네요.
답변 정말 감사드립니다.  리니어 레이아웃을 중복으로 만들고, 마진값을 줘서 사진과같이 만들긴 했습니다. 그리고 중복 레이아웃 부분에 에딧텍스트와 버튼을 넣고 패딩값을 주어서 위아래의 간격을 맞추었는데도 불구하고.. 사진과 같이 예쁘게 에딧텍스트 옆에 버튼이 나오질 않습니다 ㅠ ㅠ .. 저 부분을 어떻게 해야할까요.. 사진에서 보면 정말 예쁘게 저렇게 잘 붙어있는데..
width값을 match로 주고, height값을 wrap으로 주다 보니까
쉽지가 않네요.. 어디가 잘못되었는지도 잘 모르겠고 ㅠㅠ..
도움 부탁드려요

1개의 답변

0 추천

간단하게 되는데요.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#1fd703"
    android:orientation="vertical"
    android:padding="16dp"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#0000ff"
        android:orientation="horizontal">

        <EditText
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="버튼"/>
    </LinearLayout>
</LinearLayout>
spark (227,910 포인트) 님이 2016년 10월 16일 답변
...