AndroidではmaxHeightプロパティコントロールのない最高値を設定します
968 ワード
コントロールは次のとおりです.
クラスを書く
次のように設定します.
変換元:https://blog.haloxin.me/post/100.html
クラスを書く
public class OnViewGlobalLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {
private int maxHeight = 500;
private View view;
public OnViewGlobalLayoutListener(View view, int height) {
this.view = view;
this.maxHeight = height;
}
@Override
public void onGlobalLayout() {
if (view.getHeight() > maxHeight)
view.getLayoutParams().height = maxHeight;
}
}
次のように設定します.
View view = findViewById(R.id.devicelist_layout);
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnViewGlobalLayoutListener(view, 300));
変換元:https://blog.haloxin.me/post/100.html