我正在使用团队增压ShimmerLayout,但显示错误?

时间:2019-06-18 13:26:52

标签: java android

这是主要活动

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    Bitmap bitmap = ((BitmapDrawable)this.getDrawable()).getBitmap();

    final int w = bitmap.getWidth();
    final int h = bitmap.getHeight();
    int pixel;
    int redValue;
    int blueValue;
    int greenValue;

    for (int x = 0; x < w; x++) {
        for (int y = 0; y < h; y++) {
            pixel = bitmap.getPixel(x, y);
            redValue = Color.red(pixel);
            blueValue = Color.blue(pixel);
            greenValue = Color.green(pixel);
            if (redValue == 255 && greenValue == 254 && blueValue == 0){
                Paint paint = new Paint();
                paint.setColor(Color.BLACK);
                paint.setTextSize(35);
                canvas.drawText("Some Text", x, y, paint);
            }
        }
    }
}

这是我正在使用它的cardView

 ShimmerLayout shimmerText ;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    root = findViewById(R.id.mainlayout);
    view=root.getRootView();
    view.getBackground().setColorFilter(Color.parseColor("#efeded"), PorterDuff.Mode.DARKEN);

    //shimmer
    shimmerText  =findViewById(R.id.shimmer_Main_card);
    shimmerText.startShimmerAnimation();

    Toolbar toolbar = findViewById(R.id.toolbar);

错误消息如下:

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    android:orientation="vertical"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.026">

    <io.supercharge.shimmerlayout.ShimmerLayout
        android:id="@+id/shimmer_Main_card"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="50dp"
        android:paddingLeft="30dp"
        android:paddingRight="30dp"
        app:shimmer_animation_duration="1200">

    <android.support.v7.widget.CardView
        android:id="@+id/hostelCard"
        android:elevation="10dp"
        app:cardCornerRadius="30dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10dp">

        <RelativeLayout
            android:layout_width="330dp"
            android:layout_height="220dp"
            android:layout_gravity="center">

            <ImageView
                android:id="@+id/LocationMainImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:layout_alignParentEnd="true"
                android:layout_marginStart="0dp"
                android:layout_marginTop="7dp"
                android:layout_marginEnd="10dp"
                android:padding="4dp"
                android:src="@drawable/logo" />

            <TextView
                android:id="@+id/LocationName"
                android:layout_width="wrap_content"
                android:layout_height="38dp"
                android:layout_below="@id/LocationMainImage"
                android:layout_alignParentStart="true"
                android:layout_marginStart="3dp"
                android:layout_marginTop="-217dp"
                android:background="@color/black"
                android:text="Hostel 1"
                android:textAllCaps="true"
                android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
                android:textColor="@color/yellow" />


        </RelativeLayout>

    </android.support.v7.widget.CardView>

    </io.supercharge.shimmerlayout.ShimmerLayout>

</LinearLayout>

有人可以帮助我吗?

0 个答案:

没有答案