流体レイアウトシンプルな言葉遣い

//活動の内容を書き込みます

//テキスト入力ボックスに取得し
、編集可能なテキストflow_view.getText =()
のTextViewのTextView TextViewの新しい新=(MainActivity.this);
LinearLayout.LayoutParams LayoutParams =新新LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT、ViewGroup.LayoutParams.WRAP_CONTENTを)。
layoutParams.setMargins(100、10、10、 10); // 4は、 上から下、左、右の順序でパラメータである
//textView.setLayoutParams(layoutParams)を、
textView.setText(flow_view.getText()のtoString());.

/ /新しいビューの追加
、hestoryview.addView(のTextView)
//searchHistory.measure(100,100を);



ビューの//カスタムコンテンツ
パッケージcom.example.app_mounth.view.controlview。

輸入android.content.Context;
輸入android.graphics.Canvas。
輸入android.util.AttributeSet;
輸入android.view.View。
輸入android.view.ViewGroup;

パブリッククラスHestoryViewはのViewGroup {拡張

;プライベートint型sizeScreenWidthを

公共HestoryView(コンテキスト・コンテキスト){
この(文脈、NULL);
}

公共HestoryView(コンテキスト・コンテキスト、属性セットのATTRS){
この(文脈、attrsに、0);
}

公共HestoryView(コンテキスト・コンテキスト、属性セットattrsに、INT defStyleAttr){
スーパー(文脈、attrsに、defStyleAttr)。
}


@Override
保護されたボイドonMeasure(INT widthMeasureSpec、INT heightMeasureSpec){
super.onMeasure(widthMeasureSpec、heightMeasureSpec)。
measureChildren(widthMeasureSpec、heightMeasureSpec)。
sizeScreenWidth = MeasureSpec.getSize(widthMeasureSpec)。
}


@Overrideは、
{(ブール値がint T、INT R、INT B、INT Lを変更)ボイドonLayout保護
; 0 =左INT
int型のトップ= 0;
int型marginHorizo​​ntal = 20;
以下のために(INT i = 0; iは++; iは、のgetChildCount()<){
ビューchildAt = getChildAt(i)を、
INTはmeasuredWidth = childAt.getMeasuredWidth()。
INT measuredHeightの= childAt.getMeasuredHeight()。
IF(左+はmeasuredWidth> = sizeScreenWidth){
トップ+ = measuredHeightの。
左= 0;
}
childAt.layout(左、上、+はmeasuredWidth、トップ+ measuredHeightの左)。
+ =はmeasuredWidth + marginHorizo​​ntal左;
}
}

@Overrideは
ボイドonDraw(キャンバスキャンバス){保護
super.onDraw(キャンバス)。
}
}

 

おすすめ

転載: www.cnblogs.com/fybb/p/11250520.html