首页 > 解决方案 > 图层列表隐藏项目

问题描述

我有一个包含两个可绘制对象的图层列表(以后应该会更多)。我想隐藏所有可绘制对象并使用按钮分别激活每一个。我找不到隐藏图层列表中的项目的方法。

家庭片段

public class HomeFragment extends Fragment {

private HomeViewModel homeViewModel;
public static ImageView imageView;
public View onCreateView(@NonNull LayoutInflater inflater,
                         ViewGroup container, Bundle savedInstanceState) {
    homeViewModel =
            new ViewModelProvider(this).get(HomeViewModel.class);
    View root = inflater.inflate(R.layout.fragment_home, container, false);

    imageView = root.findViewById(R.id.imageView);
    imageView.setImageDrawable(getResources().getDrawable(R.drawable.layerlistimage));

    return root;
}
}

    imageView.setImageDrawable(getResources().getDrawable(R.drawable.layerlistimage));

图层列表图像

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/gruppe_2958"/>
<item android:drawable="@drawable/gekaufteplfanze"  />

</layer-list>

标签: androidandroid-studioandroid-fragments

解决方案


推荐阅读