Module 수준의 build.gradle에 추가

 

    dependencies{

        implementation "org.jetbrains.anko:anko-commons:$anko_version"

        ****

        ****

        ****

    }

 

Project 수준의 build.gradle에 추가

 

    buildscript{

        ****

        ext.anko_version = '0.10.5'

        ****

    }

'Android' 카테고리의 다른 글

RelaytiveLayout  (0) 2020.03.23
LinearLayout : orientation/weight  (0) 2020.03.23
무료아이콘 다운로드  (2) 2017.02.02
스플래쉬 참고  (0) 2017.02.01
[스터디] 1. 카카오톡 패스워드입력 화면 구성  (0) 2016.12.05

기준뷰 id값 설정 -> 다른 뷰에서 기준뷰의 id값을 이용하여 위치를 지정

<RelativeLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/ic_launcher_round">

 

    <TextView
        android:id="@+id/standard"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:text="기준 뷰"
        android:textColor="#FF0000"
        android:textSize="30dp"
        android:gravity="center_vertical"
        android:textAlignment="center"
        android:background="@color/colorPrimaryDark"/>

    <TextView
        android:layout_toRightOf="@+id/standard"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="false"
        android:text="1번 뷰"
        android:textColor="#FF0000"
        android:textSize="30dp"
        android:gravity="center_vertical"
        android:textAlignment="center"
        android:background="@color/colorAccent"/>

    <TextView
        android:layout_below="@+id/standard"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:text="2번 뷰"
        android:textColor="#FF0000"
        android:textSize="30dp"
        android:gravity="center_vertical"
        android:textAlignment="center"
        android:background="@color/colorPrimary"/>

</RelaytiveLayout>

'Android' 카테고리의 다른 글

Anko 라이브러리 추가  (0) 2020.03.30
LinearLayout : orientation/weight  (0) 2020.03.23
무료아이콘 다운로드  (2) 2017.02.02
스플래쉬 참고  (0) 2017.02.01
[스터디] 1. 카카오톡 패스워드입력 화면 구성  (0) 2016.12.05

 

리스트뷰 가로/세로 설정 : horizontal/vertical

layout_weight 가중치 설정

<LinearLayout
    android:layout_width="match_parent" 
    android:layout_height="500dp" 
    android:orientation="horizontal" 
    app:layout_constraintHorizontal_weight="5" 
    android:background="@mipmap/ic_launcher_round" 
    tools:ignore="MissingConstraints"> 

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

    <TextView

        android:layout_width="100dp" 
        android:layout_height="100dp" 
        android:layout_weight="1" 
        android:background="@color/colorPrimary"/> 
</LinearLayout>

 

<LinearLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    app:layout_constraintHorizontal_weight="5"
    android:background="@mipmap/ic_launcher_round"
    tools:ignore="MissingConstraints">

 

    <TextView

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

    <TextView

        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_weight="1"
        android:background="@color/colorAccent"/>

    <TextView    

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

</LinearLayout

'Android' 카테고리의 다른 글

Anko 라이브러리 추가  (0) 2020.03.30
RelaytiveLayout  (0) 2020.03.23
무료아이콘 다운로드  (2) 2017.02.02
스플래쉬 참고  (0) 2017.02.01
[스터디] 1. 카카오톡 패스워드입력 화면 구성  (0) 2016.12.05

https://material.io/icons

http://isulnara.com/wp/archives/288



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center"
android:layout_marginTop="20dp"
android:textSize="40dp"
android:text="암호"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center"
android:layout_marginBottom="10dp"
android:textSize="17dp"
android:text="카카오톡 암호를 입력해 주세요."/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom|center">

<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_marginRight="15dp"
android:src="@drawable/image1"/>

<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_marginRight="7dp"
android:src="@drawable/image1"/>

<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_marginLeft="7dp"
android:src="@drawable/image1"/>

<ImageView
android:layout_width="60dp"
android:layout_height="80dp"
android:layout_marginLeft="15dp"
android:src="@drawable/image1"/>

</LinearLayout>


</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginLeft="15dp"
android:layout_gravity="top|left"
android:src="@drawable/num_1"/>
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_gravity="top|center"
android:src="@drawable/num_2"/>
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginRight="15dp"
android:layout_gravity="top|right"
android:src="@drawable/num_3"/>
</FrameLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginLeft="15dp"
android:layout_gravity="top|left"
android:src="@drawable/num_4"/>
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_gravity="top|center"
android:src="@drawable/num_5"/>
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginRight="15dp"
android:layout_gravity="top|right"
android:src="@drawable/num_6"/>
</FrameLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginLeft="15dp"
android:layout_gravity="top|left"
android:src="@drawable/num_7"/>
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_gravity="top|center"
android:src="@drawable/num_8"/>
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginRight="15dp"
android:layout_gravity="top|right"
android:src="@drawable/num_9"/>
</FrameLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_gravity="top|center"
android:src="@drawable/num_0"/>
<ImageView
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginRight="15dp"
android:layout_gravity="top|right"
android:src="@drawable/num_"/>
</FrameLayout>


</LinearLayout>
</LinearLayout>


AndroidManifest.xml 액티비티 등록

<activity android:name=".Sub1Activity">

</activity>

activity_main.xml 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="org.androidtown.a2_3.MainActivity">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<EditText
android:id="@+id/id"
android:layout_width="120dp"
android:layout_height="50dp" />
<EditText
android:id="@+id/pw"
android:layout_width="120dp"
android:layout_height="50dp" />
</LinearLayout>
<Button
android:id="@+id/login"
android:layout_width="80dp"
android:layout_height="100dp"
android:onClick="login_onClick"
android:text="로그인"/>

</LinearLayout>

activity_sub.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">

<Button
android:id="@+id/customer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="고객 관리"
android:onClick="Custom_onClick"/>

<Button
android:id="@+id/maechul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="매출 관리"
android:onClick="Maechul_onClick"/>

<Button
android:id="@+id/goods"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="상품 관리"
android:onClick="Goods_onClick"/>

</LinearLayout>

MainActivity.java


package org.androidtown.a2_3;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void login_onClick(View view){
Intent intent = new Intent(getApplicationContext(), Sub1Activity.class);
startActivityForResult(intent, 100);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 100 && resultCode == RESULT_OK){
Toast.makeText(getApplicationContext(), data.getStringExtra("result"), Toast.LENGTH_LONG).show();
}
}
}

Sub1Activity.java


package org.androidtown.a2_3;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class Sub1Activity extends MainActivity{

Intent intent = new Intent();

@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_sub);
}

public void Custom_onClick(View v){
intent.putExtra("result", "고객 관리 클릭함");
setResult(RESULT_OK, intent);
finish();
}

public void Maechul_onClick(View v){
intent.putExtra("result", "고객 관리 클릭함");
setResult(RESULT_OK, intent);
finish();
}

public void Goods_onClick(View v){
intent.putExtra("result", "고객 관리 클릭함");
setResult(RESULT_OK, intent);
finish();
}


}


activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="org.androidtown.a2_2.MainActivity">

<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bytenumber"
android:layout_alignParentTop="true"
android:layout_margin="15dp"
android:background="#88000000"
android:gravity="left|top"
android:textSize="25dp" />

<TextView
android:id="@+id/bytenumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/btgroup"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:gravity="right"
android:textSize="18dp"/>

<LinearLayout
android:id="@+id/btgroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >

<Button
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="전송"/>

<Button
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="닫기" />

</LinearLayout>
</RelativeLayout>




MainActivity.java

package org.androidtown.a2_2;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.io.UnsupportedEncodingException;

public class MainActivity extends AppCompatActivity {

private final int LIMIT = 80;
private EditText editText;
private TextView byteLabel;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

editText = (EditText)findViewById(R.id.editText);
byteLabel = (TextView)findViewById(R.id.bytenumber);
Button send = (Button)findViewById(R.id.send);
Button exit = (Button)findViewById(R.id.exit);

editText.addTextChangedListener(new TextWatcher(){
String beforeText;

@Override
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after){
beforeText = charSequence.toString();
}

@Override
public void onTextChanged(CharSequence charSequence, int start, int before, int count){

}

@Override

public void afterTextChanged(Editable editable){
int length = showBytes();
if(length > LIMIT)
editText.setText(beforeText);
}

});

send.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Toast.makeText(getApplicationContext(), "전송되었습니다.", Toast.LENGTH_LONG).show();
}
});

exit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
MainActivity.this.finish();
}
});
showBytes();
}
private int showBytes(){
try{
int length = editText.getText().toString().getBytes("EUC-KR").length;
byteLabel.setText(length + " / 80 바이트");
return length;
}catch(UnsupportedEncodingException e){
e.printStackTrace();
}
return -1;
}
}


activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/topImage"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/rock"
android:layout_alignParentTop="true"
/>
<ImageView
android:id="@+id/bottomImage"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/paper"
android:layout_alignParentBottom="true"
/>

<Button
android:id="@+id/topButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/topImage"
android:text=""
android:onClick="topButton"
/>
<Button
android:id="@+id/bottomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/bottomImage"
android:layout_alignParentRight="true"
android:text="아래"
android:onClick="bottomButton"
/>


</RelativeLayout>

MainActivity.java
package org.androidtown.a2_1;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

ImageView topImage;
ImageView bottomImage;
Button topButton;
Button bottomButton;
Boolean check = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

topImage = (ImageView) findViewById(R.id.topImage);
bottomImage = (ImageView) findViewById(R.id.bottomImage);

topButton = (Button) findViewById(R.id.topButton);
bottomButton = (Button) findViewById(R.id.bottomButton);
}

public void topButton(View v){
changeImage();
}

public void bottomButton(View v){
changeImage();
}

private void changeImage(){
if(check == true){
check = false;
topImage.setImageResource(R.drawable.paper);
bottomImage.setImageResource(R.drawable.rock);
}else{
check = true;
topImage.setImageResource(R.drawable.rock);
bottomImage.setImageResource(R.drawable.paper);
}
}
}


+ Recent posts