Android/レイアウト/サイズ変更イベント
提供: 初心者エンジニアの簡易メモ
2019年4月16日 (火) 11:35時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==viewの縦横が変更された際に動作するサンプル== <pre> RelativeLayout layout = new RelativeLayout(mContext); layout.setLayoutParams(new RelativeLayout.La...」)
viewの縦横が変更された際に動作するサンプル
RelativeLayout layout = new RelativeLayout(mContext);
layout.setLayoutParams(new RelativeLayout.LayoutParams(MP, MP));
layoutParam = new RelativeLayout.LayoutParams(WC, WC);
layoutParam.addRule(RelativeLayout.CENTER_HORIZONTAL);
layoutParam.addRule(RelativeLayout.CENTER_VERTICAL);
TextView textView = new TextView(mContext);
textView.setText("hogehoge");
textView.setLayoutParams(layoutParam);
layout.addView(textView);
addView(layout);
layout.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
log.debug_i(TAG, "TextView onLayoutChange");
}
});
