我想以像素而不是 dp 为单位设置视图高度。
`Box(modifier = Modifier.height(100.dp))`
Run Code Online (Sandbox Code Playgroud)
在此示例中,框的高度设置为 100 dp,并且修改器函数仅接受 dp。如何设置 Box 的高度(以像素为单位)?
我有布局作为页面的viewpager。我尝试在单击deleteBtn 时删除带有动画的项目。如果页面没有滚动,它几乎可以工作(活动刚刚加载了 viewpager)。如果页面被更改,动画不会出现,但项目会像往常一样删除。请帮我修复删除时的动画外观。
查看寻呼机适配器的代码
@Override
public Object instantiateItem(ViewGroup collection, int position) {
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.item_home_pager, collection, false);
ImageView deleteBtn = (ImageView) layout.findViewById(R.id.like_btn);
deleteBtn.setOnClickListener(v -> {
Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_to_top);
layout.startAnimation(animation);
removeItem(position);
});
collection.addView(layout);
return layout;
}
public void removeItem(int position) {
personModels.remove(position);
notifyDataSetChanged();
}
@Override
public int getItemPosition(Object object) {
return PagerAdapter.POSITION_NONE;
}
@Override
public void destroyItem(ViewGroup collection, int position, Object view) {
collection.removeView((View) view);
}
@Override
public int getCount() {
return personModels.size(); …Run Code Online (Sandbox Code Playgroud)