use of android.support.design.widget.AppBarLayout.LayoutParams in project android2 by aqi00.
the class ScrollFlagActivity method initFlagSpinner.
// 初始化滚动标志的下拉框
private void initFlagSpinner() {
ArrayAdapter<String> flagAdapter = new ArrayAdapter<String>(this, R.layout.item_select, descArray);
flagAdapter.setDropDownViewResource(R.layout.item_dropdown);
Spinner sp_style = findViewById(R.id.sp_flag);
sp_style.setPrompt("请选择滚动标志");
sp_style.setAdapter(flagAdapter);
// 设置下拉框列表的选择监听器
sp_style.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// 获取可折叠布局的布局参数
LayoutParams params = (LayoutParams) ctl_title.getLayoutParams();
// 设置布局参数中的滚动标志位
params.setScrollFlags(flagArray[arg2]);
// 设置可折叠布局的布局参数。注意:第三种滚动标志一定要调用setLayoutParams
ctl_title.setLayoutParams(params);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
sp_style.setSelection(0);
}
Aggregations