https://www.iconfinder.com/

아이콘이미지가 필요할때!


사진을 어플에서 사용하려면 사진을 res폴더 drawble에 넣어둬야하고 

사진의 이름이 사진의 식별자가 되고 식별자는 소문자나 숫자로만 이뤄져있어야됨


사진을 뷰로 표현하는 위젯은 ImageView고 원하는 사진을 src속성에 지정


기본적으로 사진은 영역에 맞게 축소/확장됨

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="${relativePackage}.${activityClass}" >
 
    <ScrollView 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        > 수직스크롤
    <HorizontalScrollView 
        수평 스크롤
        >
        
    </HorizontalScrollView>    
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/bas" />
    </ScrollView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal" >
 
    <ImageView 
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/ud"/>
    </LinearLayout>
    
    <ScrollView 
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        >        
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/har" />
    </ScrollView>
</LinearLayout>
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
@Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this"얍!"0).show();
                if(count == 0){
                    iv1.setImageResource(R.drawable.har);
                    iv2.setImageResource(R.drawable.bas);
                    count = 1;
                    }
                else{
                    iv1.setImageResource(R.drawable.bas);
                    iv2.setImageResource(R.drawable.har);
                    count = 0;
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this"얍!"0).show();
                
                Drawable tmp = iv1.getDrawable();
                
                if(tmp.equals(iv1.getDrawable())){
                    iv1.setImageDrawable(iv2.getDrawable());
                    iv2.setImageDrawable(tmp);
                }
                else{
                    iv2.setImageDrawable(iv2.getDrawable());
                    iv1.setImageDrawable(tmp);
                }
            }
cs



1
2
3
4
5
6
7
8
9
10
    <EditText
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:textColor="#0c64cf"
        android:maxLength="80"
        android:id="@+id/edit"
        android:gravity="top"
        
        ></EditText>
cs


1
2
3
4
    public void onClick(View v) {
                // TODO Auto-generated method stub
                finish(); //현제 엑티비티 종료
            }
cs

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
        edit.addTextChangedListener(new TextWatcher() {
            String str;
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
                try {
                    int length = edit.getText().toString().getBytes("KSC5601").length;
                    text.setText(length + "/80Bytes");
                    if(length > 80)
                        edit.setText(str);
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }                
            }
            
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // TODO Auto-generated method stub
                str  = s.toString();
                
 
            }
            
            @Override
            public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub
            }
 
        });
cs


' IOT 기반 응용 SW과정 > Android, Arduino' 카테고리의 다른 글

Day89 안드로이드 엑티비티 전환  (0) 2016.07.25
Day88  (0) 2016.07.22
Day86  (0) 2016.07.20
Day85 안드로이드 액티비티  (0) 2016.07.19
Day84 안드로이드  (0) 2016.07.18

+ Recent posts