FrameLayout

 

1) 개요

  - 각각의 뷰를 모두 왼쪽 상단 기준으로 쌓아 올리는 방식으로 배치하는 레이아웃

  - 먼저 추가된 View위로 나중에 추가된 View가 겹겹이 쌓이게 된다.

 

2) FrameLayout의 계층 만들기

먼저 추가한 View위에 나중에 추가한 View가 쌓이는 형태가 된다 (소스코드는 아래 참조)

<FrameLayout 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"
    tools:context=".MainActivity">

    <!-- FrameLayout의 계층 만들기 먼저 만든 순서대로 아래에 위치-->
    <!-- 1번 Layout -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorAccent">
    </LinearLayout>

    <!-- 2번 Layout -->
    <LinearLayout
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:background="@color/colorPrimaryDark">
    </LinearLayout>

    <!-- 3번 Layout -->
    <LinearLayout
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:background="@color/colorPrimary">
    </LinearLayout>

</FrameLayout>

'Android > Layout' 카테고리의 다른 글

Layout - 02.RelativeLayout  (0) 2019.04.03
Layout - 01. LinearLayout  (0) 2019.04.03
블로그 이미지

모데스티

,

LinearLayout 

 

  1) 개요

    - 부모 컨테이너와의 상대적 위치 또는 다른 뷰와의 상대적 위치로 배치하는 레이아웃

 

  2) 부모 컨테이너와의 상대적 위치를 이용

    - layout_alignParent(Top, Bottom, Left, Right) : 부모 컨테이너의 위, 아래, 왼쪽, 오른쪽에 맞춰 배치

    - layout_center(Horizontal, Vertical, Parent) : 부모 컨테이너의 수평 중앙, 수직 중앙, 정중앙에 배치

 

부모 컨테이너와의 상대적 위치를 이용한 배치 (소스코드는 아래 참조)

<RelativeLayout 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"
    tools:context=".MainActivity">

    <!-- 1번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentTop="true"
        android:text="1"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 2번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerHorizontal="true"
        android:text="2"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 3번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentRight="true"
        android:text="3"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 4번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerVertical="true"
        android:text="4"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 5번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:text="5"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 6번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:text="6"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 7번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentBottom="true"
        android:text="7"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 8번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:text="8"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 9번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:text="9"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

</RelativeLayout>

  

  3) 다른 뷰와의 상대적 위치를 이용

     - layout_to(Right, Left)of : 기준이 되는 뷰의 오른쪽, 왼쪽에 배치

       (단, 상하의 위치를 지정하지 않으면 기본값인 Top으로 배치)

     - layout_(above, below) : 기준이 되는 뷰의 위, 아래에 배치

       (단, 좌우의 위치를 지정하지 않으면 기본값인 Left로 배치)

다른 뷰와의 상대적 위치를 이용한 배치 (소스코드는 아래 참조)

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- 1번 TextView -->
    <TextView
        android:id="@+id/textview01"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:text="1"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 2번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_above="@id/textview01"
        android:layout_toLeftOf="@id/textview01"
        android:text="2"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 3번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_toRightOf="@+id/textview01"
        android:layout_above="@id/textview01"
        android:text="3"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 4번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_below="@id/textview01"
        android:layout_toLeftOf="@id/textview01"
        android:text="4"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

    <!-- 5번 TextView -->
    <TextView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_below="@id/textview01"
        android:layout_toRightOf="@id/textview01"
        android:text="5"
        android:textSize="70sp"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark" />

</RelativeLayout>

'Android > Layout' 카테고리의 다른 글

Layout - 03.FrameLayout  (0) 2019.04.09
Layout - 01. LinearLayout  (0) 2019.04.03
블로그 이미지

모데스티

,

1. LinearLayout 

 

  1) 개요

    - 세로(vertical) 또는 가로(horizontal)의 단일 방향으로 모든 하위 항목을 정렬하는 뷰 

    - Layout의 orientation의 속성으로 방향을 지정할 수 있다.

 

  2) layout_orientation

    - Layout을 세로로 배치할 것인지, 가로로 배치할 것인지 설정할 수 있다.

    - layout_orientation값을 주지 않을 경우 가로로 배치하는 것이 기본

 

orientation 속성을 생략하거나 horizontal로 설정한 경우 (소스코드는 아래 참조)

<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:orientation="horizontal"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorPrimaryDark"/>

    <TextView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorPrimary"/>

    <TextView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorAccent"/>

</LinearLayout>

 

orientation 속성을 vertical로 설정한 경우 (소스코드는 아래 참조)

<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:orientation="vertical"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorPrimaryDark"/>

    <TextView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorPrimary"/>

    <TextView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="@color/colorAccent"/>

</LinearLayout>

 

  2) layout_weight

   - LinearLayout의 하위 뷰의 크기를 지정한 만큼의 가중치를 매겨 영역을 할당할 수 있다.

   - LinearLayout의 orientation에 따라 가중치가 적용되는 크기의 방향이 다름

   - orientation을 vertical로 설정하고 자식뷰의 height를 0이 아닌 다른 값으로 설정하거나, horizontal로 설정하고

     자식뷰의 width를 0이 아닌 다른 값으로 설정한 경우 가중치가 아닌 width나 height에 설정한 값이 우선 적용된다.

 

orientation 속성을 horizontal로 설정하고 TextView에 가중치를 준 결과 (소스코드는 아래 참조)

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <TextView
        android:layout_width="0dp"
        android:layout_weight="3"
        android:layout_height="100dp"
        android:background="@color/colorAccent"/>

    <TextView
        android:layout_width="0dp"
        android:layout_weight="2"
        android:layout_height="100dp"
        android:background="@color/colorPrimary"/>

    <TextView
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_weight="1"
        android:background="@color/colorPrimaryDark"/>

</LinearLayout>

 

orientation 속성을 vertical로 설정하고 TextView에 가중치를 준 결과 (소스코드는 아래 참조)

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="100dp"
        android:layout_weight="3"
        android:layout_height="0dp"
        android:background="@color/colorAccent"/>

    <TextView
        android:layout_width="100dp"
        android:layout_weight="2"
        android:layout_height="0dp"
        android:background="@color/colorPrimary"/>

    <TextView
        android:layout_width="100dp"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@color/colorPrimaryDark"/>

</LinearLayout>

'Android > Layout' 카테고리의 다른 글

Layout - 03.FrameLayout  (0) 2019.04.09
Layout - 02.RelativeLayout  (0) 2019.04.03
블로그 이미지

모데스티

,

1. Component의 크기

  1) layout_width : Component의 너비, 폭

  2) layout_height : Component의 높이

width와 height

 

2. ViewComponent의 크기를 지정하는 방식

  1) 수치로 지정

     - px : 디바이스의 스크린에 들어가는 실제 픽셀 (이미지의 파랑 점 1개).

     - dp : 안드로이드 폰의 다양한 해상도를 지원하기 위해 만든 단위입

px단위로 지정
dp단위로 지정

  2) WrapContent : View 내용의 크기에 맞게 지정

TextView의 내용의 크기로 지정

  3) MatchParent : View의 크기를 부모의 크기와 동일하게 지정

TextView의 부모의 크기로 지정

 

3. ViewComponent의 여백을 설정하는 방식

  1) layout_margin : View와 View사이의 간격

    - layout_margin(Left, Top, Bottom, Right, Start, End, Vertical, Horizontal)

1번과 2번 View사이의 간격을 설정하지 않았다
2번 View의 속성에 layout_marginLeft 값을 설정한 결과

 

  2) Padding : View와 View의 내용 사이의 간격

   - padding(Left, Top, Bottom, Right, Start, End, Vertical, Horizontal)

비교를 위해 View의 크기를 wrap_content로 설정

 

view에 padding을 설정한 결과

 

블로그 이미지

모데스티

,

View - 02.TextView

Android/View 2019. 3. 27. 20:27

TextView를 추가하는 방식 01. Design 탭을 이용하는 방법

 

1. Common의 하위 리스트의 TextView를 Drag & Drop 방식으로 추가
2. Drag & Drop 으로 추가 후 Attribute 설정을 할 수 있다

 

 

TextView를 추가하는 방식 01. Text 탭에서 XML 수정으로 추가하는 방법

 

1. Design탭에서 추가한 TextView가 추가된 것을 확인할 수 있다.
2. XML로 TextView를 추가
3. TextView가 추가된 것을 확인 할 수 있다.

 

'Android > View' 카테고리의 다른 글

View - 01.개요  (0) 2019.03.26
블로그 이미지

모데스티

,

View - 01.개요

Android/View 2019. 3. 26. 23:39

1. 화면의 구성


  1) XML

- VIEW를 그리는데 사용되는 언어

- DSL ( Domain Specific Language ) : 도메인 특화 언어


  2) ViewComponent

- 안드로이드 화면을 구성하는 요소

- TextView, ImageView, Button 등이 있다.



2. ViewComponent의 종류


  1) Parent ViewComponent

- LinearLayout

- RelativeLayout

- FrameLayout

- ScrollView


  2) Child ViewComponent

- TextView

- ImageView


3. Attribute


  1) 공통속성

- Width

- Height

- Background


  2) 각각의 ViewComponent가 지닌 속성


4. 화면 크기 단위


  1) Px : 화면의 크기와 상관 없이 지정한 크기 그대로 보여준다.

  2) Dp : 화면대비 동일한 비율의 크기로 보여준다.

'Android > View' 카테고리의 다른 글

View - 02.TextView  (0) 2019.03.27
블로그 이미지

모데스티

,


① 소스내용


package dept;

 

import java.io.*;

import java.sql.*;

 

import javax.servlet.*;

import javax.servlet.http.*;

import javax.sql.*;

 

import common.*;

 

public class DeptServlet extends HttpServlet {

    @Override

    protected void doGet(HttpServletRequest request, HttpServletResponse response)

            throws ServletException, IOException {

        response.setCharacterEncoding("euc-kr");

        PrintWriter out = response.getWriter();

       

        // 1. DB 연결

        Connection conn = null;

        Statement stmt = null;

        ResultSet rs = null;

       

        try {

            // InitListener에서 가지고 오기

            DataSource ds = (DataSource)getServletContext().getAttribute("ds");

           

            conn = ds.getConnection();

            stmt = conn.createStatement();

            rs = stmt.executeQuery("select * from dept");

            // select * from dept

            // 2. 쿼리문 날려서 결과를 가져온다.

           

            // 3. 브라우저에 결과를 출력한다.

            out.println("<table border='5' align='center' width='500' bordercolor='red'>");

            out.println("<tr>");

            out.println("<th>번호</th>");

            out.println("<th>deptno</th>");

            out.println("<th>deptname</th>");                        

            out.println("<th>loc</th>");

            out.println("</tr>");

            int i=1;

            while(rs.next()){

               out.println("<tr align='center' color='red'>");

               out.println("<th>"+i+"</th>");              

               out.println("<td>"+rs.getString(1)+"</td>");                           

               out.println("<td>"+rs.getString(2)+"</td>");                           

               out.println("<td>"+rs.getString(3)+"</td>");

               out.println("</tr>");

               i++;

            }

            out.print("</table>");

        }catch (SQLException e) {

                e.printStackTrace();

        } finally {

            try {

                if(rs != null)rs.close();

            } catch (SQLException e) {

                e.printStackTrace();

            } try {

                if(stmt != null)stmt.close();

            } catch (SQLException e) {

                e.printStackTrace();

            } try {

                if(conn != null)conn.close();

            } catch (SQLException e) {

                e.printStackTrace();

            }

        }   

    }

}

 


② 실행결과


블로그 이미지

모데스티

,
※ Connection Pool 만들기

① http://tomcat.apache.org/ 에 접속


② JDBC DataSources 선택


③ Database Connection Pool에서 Oracle 8i, 9i & 10g 선택


④ 빨간 박스안의 내용 복사


⑤ Servers의 Context.xml에 붙여넣기




⑥ 빨간 박스안의 내용 복사


⑦ PilotProject안의 web.xml에 붙여넣은 후 Listener설정



⑧ InitListener Class만들기


⑨ 박스안의 내용 복사 후 클래스안에 붙여넣기



Ctrl + Shift + O를 눌러 javax.sql.DataSource와 javax.naming.Context를 import










'Dev. Story > Dev. Ref' 카테고리의 다른 글

WEB 6일차 첫번째) Servlet소스코드 추가하기  (0) 2012.09.23
블로그 이미지

모데스티

,

※ Eclipse에 Servlet Source Code추가하기 


①  http://tomcat.apache.org/ 사이트에서 톰캣버전 선택


② Source Code zip파일 다운로드


③ 저장 후 Eclipse 환경설정하기


④ Source추가하기


⑤ 다운로드 받은 Source Code 선택


⑥ Encoding은 Default로 둔다.


⑦ 추가 확인

'Dev. Story > Dev. Ref' 카테고리의 다른 글

WEB 6일차 두번째) Eclipse에서 ConnectionPool 만들기  (0) 2012.09.23
블로그 이미지

모데스티

,

※날짜함수※

날짜함수의 참조사이트 >> http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions002.htm#i88891

  

1) sysdate

>> 실행할 때의 날짜가 YY/MM/DD형태로 출력된다. 

  

2) systimestamp

>> 실행할 때의 시간대까지 출력한다.
 

  

3) 날짜 타입의 계산

 

>> sysdate에 숫자를 더하거나 빼서 그 숫자만큼 지난 날짜 또는 이전 날짜를 구할 수 있다.
 

 

>> systimestamp도 숫자를 더하거나 빼서 그 숫자만큼 지난 날짜 또는 이전 날짜를 구할 수 있다.
 

  

4) ADD_MONTH

>> n달 후의 날짜를 구할 수 있다.

 

'Oracle' 카테고리의 다른 글

Oracle 5일차 첫번째) 정규식  (0) 2012.09.14
Oracle 4일차 네번째) 테스트  (0) 2012.09.14
Oracle 4일차 세번째) 정규식  (0) 2012.09.14
Oracle 4일차 두번째) 문자함수  (0) 2012.09.14
Oracle 4일차 첫번째) 숫자함수  (0) 2012.09.14
블로그 이미지

모데스티

,