サイズが 130*160dip のウィジェットがあります。サイズ変更可能なウィジェットを作成したいのですが、すでに追加しましandroid:resizeMode="horizontal|vertical"
たが、レイアウトは固定サイズであるため、サイズ変更は何にも影響しません。
私のレイアウト(xmlよりも優れていると思います:)):
==========LinearLayout===========
= -TextView- =
= =LinearLayout= =LinearLayout= =
= = TextView = = TextView = =
= = TextView = = TextView = =
= = TextView = = TextView = =
= = TextView = = TextView = =
= = TextView = = TextView = =
= = TextView = = TextView = =
= ============================= =
= TextView =
=================================
ユーザーがウィジェットのサイズを変更した場合、アスペクト比 (13*16) を維持し、新しいサイズに合わせてテキストビューのサイズを変更する必要があります。
私のアクティビティの 1 つで、拡張されたカスタム (ウェイトベース) レイアウトで以下を使用しました。
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
[...]
int count = getChildCount();
for (int i = 0; i < count; i++) {
[...]
if (child instanceof TextView) {
((TextView) child).setTextSize(TypedValue.COMPLEX_UNIT_PX,
ch * 7 / 10); //ch=child height
}
}
それはうまく機能していますが、ウィジェットにカスタム レイアウト (または TextViews) を使用することはできません。
ウィジェットのサイズを変更するときにこの動作を取得するにはどうすればよいですか?
メチン