일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- git flow
- #3차원배열
- #bubbleSort
- #JAVASCRIPT
- html youtube
- #binary
- #C++ 연산자함수오버로딩
- html multimedia
- relative path
- mac terminal command
- #성적관리프로그램
- html code
- html object
- html id
- #2차원배열
- html plug-in
- 하이퍼레저패브릭
- 토큰경제
- hyperledger transaction
- border-box
- html5 new tag
- #CallByAddress
- html video
- #1차원배열
- #자바상속#자바이즈어#is~a
- #C++ has~a
- #다차원포인터
- #android activity
- docker example
- html charset
Archives
- Today
- Total
A sentimental robot
My xml 본문
package com.example.i310_54.myapplication08;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import java.util.Random;
class Tiger extends View {
int flag = 0;
public Tiger(Context context) {
super(context);
}
public Tiger(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public Tiger(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.RED);
canvas.drawRect(10 - flag, 20 - flag, 30 + flag, 40 + flag, paint);
}
void inC(){
flag+=20;
invalidate();
}
void deC(){
flag-=20;
invalidate();
}
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void f1(View view) {
Tiger tiger = findViewById(R.id.cv);
tiger.inC();
}
public void f2(View view) {
Tiger tiger = findViewById(R.id.cv);
tiger.deC();
}
}
<?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"
tools:context="com.example.i310_54.myapplication08.MainActivity"
android:orientation="vertical"
android:weightSum="1"
>
<com.example.i310_54.myapplication08.Tiger
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:id="@+id/cv"
/>
<Button
android:id="@+id/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UPSIZING"
android:onClick="f1"
/>
<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="downSizing"
android:onClick="f2"
/>
</LinearLayout>
'Android Studio' 카테고리의 다른 글
Menu (0) | 2018.02.07 |
---|---|
Thread를 이용한 UI (0) | 2018.02.07 |
Customizing (0) | 2018.02.06 |
OnTouch (0) | 2018.02.06 |
RelativeLayout (0) | 2018.02.06 |