课设常用代码

//新建一个BlankFragment
BlankFragment blankFragment  = new BlankFragment();

//布局替换成Fragment
        getSupportFragmentManager().beginTransaction().add(R.id.imageView,blankFragment).commit();



//滑动布局
 <!--主题滑动部分-->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/constraintLayout2"
        android:layout_width="409dp"
        android:layout_height="729dp"
        android:layout_marginTop="140dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/constraintLayout">

        <androidx.core.widget.NestedScrollView
            android:layout_width="407dp"
            android:layout_height="727dp"
            android:fillViewport="true"
            android:contentDescription="主体部分类"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                
            </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.core.widget.NestedScrollView>
    </androidx.constraintlayout.widget.ConstraintLayout>



//加载网络图片
ImageView imageView = findViewById(R.id.imageView4);
        String url = "http://t13.baidu.com/it/u=123351041,2873697704&fm=224&app=112&f=JPEG?w=500&h=500.jpg";

        //加载图片  添加网络权限
        Glide.with(this)
                .load(url)
                .apply(RequestOptions.bitmapTransform(new RoundedCorners(100)))
                .into(imageView);



//整体上移,包括状态栏
ImmersionBar.with(this).init();



//轮播图

List<String> list = new ArrayList<>();
        list.add("https://img2.baidu.com/it/u=671627531,2759942804&fm=253&fmt=auto&app=138&f=JPEG?w=900&h=500.jpg");
        list.add("https://img1.baidu.com/it/u=4158579023,1583009125&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=504.jpg");

        Banner banner = findViewById(R.id.banner);
        banner.setAdapter(new BannerImageAdapter<String>(list) {
            @Override
            public void onBindView(BannerImageHolder holder, String data, int position, int size) {
                //打开网络权限
                Glide.with(holder.itemView)
                        .load(data)
                        .into(holder.imageView);

            }
        });

//先在布局文件中手动加入Banner
<com.youth.banner.Banner
            android:id="@+id/banner"
            android:layout_width="match_parent"
            android:layout_height="180dp"
            android:layout_marginStart="30dp"
            android:layout_marginTop="180dp"
            android:layout_marginEnd="30dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

//给轮播图添加指示点
banner.setIndicator(new CircleIndicator(this));
        banner.setIndicatorRadius(100);


//Fragment中点击事件
View view = inflater.inflate(R.layout.first_fragment1, container, false);
        
        ImageView imageView = view.findViewById(R.id.imageView10);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                
            }
        });
        // Inflate the layout for this fragment
        return view;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值