Activity에서 view 설정하기

<edittext 읽기만 가능 하기>
editText.setFocusable(false);
editText.setClickable(false);

 

<edittext에 포커스 되는것 막는 방법>

바로 위의 layout에
android:focusable=”true”
android:focusableInTouchMode=”true”
를 추가해준다.

http://theeye.pe.kr/archives/1423

 

<edittext에서 settext할때>

EditText editText = (EditText)findViewById(R.id.edit_text);
editText.setText(“Google is your friend.”, TextView.BufferType.EDITABLE);

 

<Imageview margin주기>

myView.setMargins(left in dp , top in dp , right in dp , bottom in dp ) ;

http://www.androidpub.com/index.php?mid=android_dev_qna&listStyle=webzine&document_srl=2011709&sort_index=regdate&order_type=asc

https://stackoverflow.com/questions/6042111/help-about-view-setmarginsleft-top-right-bottom

<imageview에 코드로 마진주기>
image = (ImageView) findViewById(R.id.imageID);
MarginLayoutParams marginParams = new MarginLayoutParams(image.getLayoutParams());
marginParams.setMargins(left_margin, top_margin, right_margin, bottom_margin);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
image.setLayoutParams(layoutParams);

 

<imageview image바꿀때>

myImgView.setImageResource(R.drawable.monkey);
를 쓴다.

만약 비우고 싶다면,

viewToUse.setImageResource(0);

https://stackoverflow.com/questions/2974862/changing-imageview-source

 

<imageview에 colorfilter로 음영주기>

imageView.setColorFilter(Color.argb(255, 255, 255, 255));

https://stackoverflow.com/questions/20121938/how-to-set-tint-for-an-image-view-programmatically-in-android

http://swalloow.tistory.com/89

 

<imageview image가져와서 넣어주기>

Drawable drawable = imageViewA.getDrawable();
if(drawable != null){
    imageViewB.setImageDrawable(drawable);
}

https://stackoverflow.com/questions/35202096/get-imageview-src-programmatically

<view 안보이게 설정>
bt_dateinfo.setVisibility(bt_dateinfo.GONE);

bt_dateinfo.getVisibility() == View.VISIBLE 로 확인함

<text color지정>
text.setTextColor(Color.parseColor(“#FFFFFF”));

 

<background color설정>

step1.setBackgroundColor(Color.parseColor("#000000"));

 

<textview gravity 설정>
labelTV.setGravity(Gravity.CENTER | Gravity.BOTTOM);

 

<textview top만 margin주기>

TextView tv = (TextView)findViewById(R.id.tv_1);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)tv.getLayoutParams();
params.topMargin = 10;
tv.setLayoutParams(params);

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s