'안드로이드'에 해당되는 글 13건

  1. 2014.09.17 ScrollView fill Parent View
  2. 2014.09.12 ScrollView 이동하기 (1)
  3. 2014.08.26 안드로이드 webview 텍스트 선택 막기
  4. 2014.08.18 안드로이드 네트워크 상태 확인
  5. 2014.08.12 이미지 flip 시키기
  6. 2014.08.12 Android WebView에 세션(쿠키) 공유하기
  7. 2014.08.12 모든 액티비티 종료 시키기
2014.09.17 09:52

ScrollView fill Parent View

ScrollView에 아래 property 추가

android:fillViewport="true"



[출처] View inside ScrollView doesn't take all place

[참고] ScrollView’s handy trick

Trackback 0 Comment 0
2014.09.12 09:34

ScrollView 이동하기

맨 아래로 이동

 mScroll.fullScroll(View.FOCUS_DOWN); 


맨 위로 이동

 mScroll.fullScroll(View.FOCUS_UP); 

Trackback 0 Comment 1
2014.08.26 14:28

안드로이드 webview 텍스트 선택 막기

웹뷰에 들어가는 html의 css에 다음 element 추가

-webkit-user-select: none;


[출처] webview no selection/copy&paste

Trackback 0 Comment 0
2014.08.18 17:01

안드로이드 네트워크 상태 확인

boolean isNetworkConnectionAvailable() {
	ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
	NetworkInfo info = cm.getActiveNetworkInfo();
	if (info == null)
		return false;
	State network = info.getState();
	return (network == NetworkInfo.State.CONNECTED || network == NetworkInfo.State.CONNECTING);
}


[출처] How to check the network availability?

Trackback 0 Comment 0
2014.08.12 17:25

이미지 flip 시키기

1. 플립 메소드

public static final int FLIP_VERTICAL = 1;
public static final int FLIP_HORIZONTAL = 2;

private Bitmap flipImage(Bitmap src, int type) {
	// create new matrix for transformation
	Matrix matrix = new Matrix();
	// if vertical
	if (type == FLIP_VERTICAL) {
		// y = y * -1
		matrix.preScale(1.0f, -1.0f);
	}
	// if horizonal
	else if (type == FLIP_HORIZONTAL) {
		// x = x * -1
		matrix.preScale(-1.0f, 1.0f);
		// unknown type
	} else {
		return null;
	}

	// return transformed image
	return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(),
			matrix, true);
}


2. 이미지 플립 시키미(호출쪽)

ImageView imgView = (ImageView) findViewById(R.id.imageView);
imgView.setImageBitmap(flipImage(BitmapFactory.decodeResource(getResources(), R.drawable.img), FLIP_VERTICAL );


[출처] Image Flipping (Mirroring) in ImageView (Android)

Trackback 0 Comment 0
2014.08.12 17:03

Android WebView에 세션(쿠키) 공유하기

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

	WebViwe webView = (WebView) findViewById(R.id.webview);

	CookieSyncManager.createInstance(this);
	cookieManager = CookieManager.getInstance();
	CookieSyncManager.getInstance().startSync();

	//도메인 url, 쿠키
	cookieManager.setCookie("user domain url", "cookie value");
}


[참조] Syncing cookies between an HttpClient and a WebView

Trackback 0 Comment 0
2014.08.12 16:57

모든 액티비티 종료 시키기

package com.hrupin;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

public abstract class AppBaseActivity extends Activity {
	public static final String FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION = "com.hrupin.FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION";
	private BaseActivityReceiver baseActivityReceiver = new BaseActivityReceiver();
	public static final IntentFilter INTENT_FILTER = createIntentFilter();

	private static IntentFilter createIntentFilter() {
		IntentFilter filter = new IntentFilter();
		filter.addAction(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION);
		return filter;
	}

	protected void registerBaseActivityReceiver() {
		registerReceiver(baseActivityReceiver, INTENT_FILTER);
	}

	protected void unRegisterBaseActivityReceiver() {
		unregisterReceiver(baseActivityReceiver);
	}

	public class BaseActivityReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context context, Intent intent) {
			if (intent.getAction().equals(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION)) {
				finish();
			}
		}
	}

	protected void closeAllActivities() {
		sendBroadcast(new Intent(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION));
	}
}


적용해야 하는 액티비티 구현시 AppBaseActivity를 상속하고

액티비티들을 종료하고 싶은때 sendBroadCast(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION) 메소드 호출 


[출처] How to finish all activities in your Android application through simple call

Trackback 0 Comment 0