글을 읽고 아무 생각 없이 테스트 해봄.
스트레스 많이 받아서 힘든데 이상하게 코딩하면 스트레스가 풀리는 것 같네;;
나 변태인가? ㅋㅋ
전에 스마트폰에서 블루투스 키보드로 코딩하면 변태라고 하더만 ㅋㅋ
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class Button_testActivity extends Activity {
/** Called when the activity is first created. */
int btnHsize;
int btnWsize;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button bt01 = (Button) findViewById(R.id.btn1);
final TextView tv01 = (TextView) findViewById(R.id.tv1);
final TextView tv02 = (TextView) findViewById(R.id.tv2);
bt01.setListener(new Button.Listener(){
public void (View v) {
btnHsize = bt01.getHeight();
btnWsize = bt01.getWidth();
tv01.setText("H Size : " + Integer.toString(btnHsize));
tv02.setText("W Size : " + Integer.toString(btnWsize));
Toast t1 = Toast.makeText(getApplication(), Integer.toString(btnHsize), Toast.LENGTH_SHORT);
t1.show();
Toast t2 = Toast.makeText(getApplication(), Integer.toString(btnWsize), Toast.LENGTH_SHORT);
t2.show();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/btn1"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView1"
android:textSize="20dp"/>
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView2"
android:textSize="20dp"/>
</LinearLayout>
</LinearLayout>
Button 크기 보임?
android:layout_width="100dp"
android:layout_height="100dp"
이건데 HTC HD2에 직접 구동했더니
1.5배되서 150이라고 뜸
직접 해보는 게 좋을 듯 ㅋ
댓글 0