2011년 2월 15일 화요일

layout width, hieght 값 설정 방법 - Java Code

1. width값에 해당하는 dip값 integer형 선언
2. float 형 변수 선언
3. layout 세팅

int width_dip = 180;

float width_layout = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, width_dip, r.getDisplayMetrics());

setLayoutParams( new RelativeLayout.LayoutParams( (int)width_layout , LayoutParams.FILL_PARENT) );

height 값도 마찬가지...

2010년 11월 19일 금요일

TextView 한글의 Bold 처리


text.setText("한글 볼드 테스트"); 
text.setPaintFlags(text.getPaintFlags() | Paint.FAKE_BOLD_TEXT_FLAG);

2010년 11월 18일 목요일

스크롤바 없애기

android:scrollbars="@null"

2010년 11월 11일 목요일

단말의 DIP, WIDTH, HEIGHT 값 구하기

DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

density = displaymetrics.densityDpi;
width = displaymetrics.widthPixels;
height = displaymetrics.heightPixels;

2010년 11월 1일 월요일

Bitmap <--> Drawable

[Bitmap to Drawable]
BitmapDrawable bitmapDrawable = (BitmapDrawable)bitmap;
Drawable drawable = (Drawable)bitmapDrawable;

Bitmap bitmap = new Bitmap (...);
Drawable drawable = new BitmapDrawable(bitmap);

[Drawable to Bitmap] 
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
d.setBounds(0, 0, w, h);
d.draw(canvas);

2010년 10월 22일 금요일

tile background 방법

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat">


/res/drawable/backrepeat.xml 생성한다.


<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/back" 
android:tileMode="repeat" />

2010년 10월 13일 수요일

스크롤 관련

1. 스크롤 버튼 : setFastScrollEnabled(true)
2. 스크롤 할때만 나타나게 하기 : android:fadeScrollbars="true"
3. 스크롤 이미지 변경 
    android:scrollbarThumbVertical="@drawable/..."
    android:scrollbarThumbHorizontal="@drawable/..."
4. 스크롤의 background
    android:scrollbarTrackVertical="@drawable/..."
    android:scrollbarTrackHorizontal="@drawable/..."