设置首页轮播图的样式

This commit is contained in:
huangrui 2024-05-22 17:43:22 +08:00
parent b7f31eb7de
commit 6ce096dfd6
4 changed files with 19 additions and 17 deletions

View File

@ -47,7 +47,7 @@ dependencies {
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation ("io.github.youth5201314:banner:2.2.3")
implementation ("io.github.youth5201314:banner:2.2.2")
implementation ("com.github.bumptech.glide:glide:4.15.1")
// implementation ("com.baidu.mapapi:mapapi:5.0.0")

View File

@ -80,10 +80,9 @@ public class Station extends AppCompatActivity {
try {
Gson gson = new Gson();
Station_item station_item = gson.fromJson(result,Station_item.class);
stationItemList.addAll(station_item);
// stationItemList.addAll(station_item);
myAdapter.notifyDataSetChanged();
// title.setText(student.class1.classname);
// names.setText(student.name);
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -12,6 +12,8 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.adapter.BannerImageAdapter;
@ -39,12 +41,18 @@ public class shouye extends AppCompatActivity {
public void onBindView(BannerImageHolder holder, String data, int position, int size) {
Glide.with(holder.itemView)
.load(data)
.apply(RequestOptions.bitmapTransform(new RoundedCorners(30)))
.into(holder.imageView);
}
});
banner.setIndicator(new CircleIndicator(this));
banner.setIndicatorRadius(100);
banner.setIndicator(new CircleIndicator(this));
banner.setIndicatorRadius(5);
banner.setBannerGalleryEffect(10,10,3) ;
banner.setBannerRound(30);
// banner.setPageChangeDuration(800); // 滑动时的动画时间
// banner.setDelayTime(3000); // 自动切换的时间间隔
banner.setScrollTime(800);
message.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -7,14 +7,6 @@
tools:context=".shouye"
android:background="#F3F3F3">
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="250dp"-->
<!-- android:background="#0007FE"-->
<!-- tools:layout_editor_absoluteX="0dp"-->
<!-- tools:layout_editor_absoluteY="82dp">-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="100dp"
@ -156,15 +148,18 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- app:layout_constraintTop_toTopOf="@+id/constraintLayout2" -->
android:layout_height="match_parent"
android:background="#F3F3F3">
<com.youth.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@color/black"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#F3F3F3"
app:banner_radius="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"