как использовать оформление предмета в представлении реселлера в диалоге с закругленными углами и прозрачным фоном - PullRequest
0 голосов
/ 28 мая 2019

Я использую диалоговое окно, и в этом диалоговом окне я использую обзор переработчика, и я также устанавливаю настраиваемый фон для рисования с закругленными углами для этого диалога. проблема заключается в том, что всякий раз, когда я пытаюсь установить декорацию предмета для просмотра переработчика, в нижних углах диалога появляются странные линии, как здесь 1 и здесь 2 Я думаю, это потому, что я установил прозрачность фона диалога. Я хочу знать, как удалить эти строки

Элемент декорации

public ItemDecoration(Context context) {

        mDivider = context.getResources().getDrawable(R.drawable.recycler_horizontal_divider);
    }

    @Override
    public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
        int left = parent.getPaddingLeft();
        int right = parent.getWidth() - parent.getPaddingRight();

        int childCount = parent.getChildCount();
        for (int i = 0; i <= childCount-2; i++) {
            View child = parent.getChildAt(i);

            RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

            int top = child.getBottom() + params.bottomMargin;
            int bottom = top + mDivider.getIntrinsicHeight();

            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }

фон для диалога

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"></solid>
    <corners android:radius="@dimen/viewsRadius"></corners>
</shape>

Макет для диалога

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/rounded_corners_dialog_back"
    >


    <TextView
        android:id="@+id/dialogNameTxt"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_alignParentStart="true"
        android:layout_marginStart="10dp"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:tag="bold"
        android:text=""
        android:textColor="@color/black"
        android:textSize="@dimen/textSize"
        android:textStyle="" />

    <TextView
        android:id="@+id/closeBtn"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp"
        android:tag="icon"
        android:gravity="center"
        android:background="@drawable/yellow_circle"
        android:textColor="@color/white"
        android:textSize="@dimen/textSize"
        android:text="@string/closeIcon" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/dialogList"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_below="@id/closeBtn"
        android:tag="bold" />

    <Button
        android:id="@+id/addBtn"
        android:layout_width="match_parent"
        android:layout_height="@dimen/viewsHeight"
        android:text="@string/add"
        android:tag="bold"
        android:layout_margin="10dp"
        android:textColor="@color/white"
        android:textAllCaps="false"
        android:background="@drawable/rounded_yellow_button"
        android:layout_below="@id/dialogList"
        />

  <android.support.constraint.ConstraintLayout
      android:visibility="gone"
      android:id="@+id/commentView"
      android:layout_width="match_parent"
      android:layout_below="@id/dialogList"
     android:layout_margin="10dp"
      android:layout_height="wrap_content">

      <EditText
          android:id="@+id/messageEditTxt"
          android:layout_width="0dp"
          android:layout_height="@dimen/viewsHeight"
          android:background="@drawable/edit_text_back"
          android:ems="10"
          android:hint="@string/write_a_comment"
          android:inputType="textPersonName"
          android:paddingStart="10dp"
          android:paddingEnd="10dp"
          android:layout_marginEnd="10dp"
          android:tag="regularFont"
          android:textColor="@color/black"
          android:textCursorDrawable="@null"
          app:layout_constraintEnd_toStartOf="@+id/sendBtn"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintBottom_toBottomOf="parent" />

      <TextView
          android:id="@+id/sendBtn"
          android:layout_width="@dimen/circleButtonDimension"
          android:layout_height="@dimen/circleButtonDimension"
          android:background="@drawable/yellow_circle"
          android:gravity="center"
          android:padding="@dimen/iconTextPadding"
          android:tag="icon"
          android:text="@string/sendIcon"
          android:textColor="@color/white"
          android:textSize="@dimen/iconTextSize"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"/>

  </android.support.constraint.ConstraintLayout>


    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/dialogNameTxt"
        android:id="@+id/cancelDialogView"
        android:visibility="gone">

        <TextView
            android:id="@+id/message"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginBottom="20dp"
            android:layout_marginTop="10dp"
            android:tag="regularFont"
            android:text="@string/confirm_cancel"
            android:textColor="@color/black"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView3"
            app:layout_constraintBottom_toTopOf="@id/yesBtn"/>

        <Button
            android:id="@+id/yesBtn"
            android:layout_width="0dp"
            android:layout_height="@dimen/viewsHeight"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/rounded_yellow_button"
            android:text="@string/yes"
            android:textAllCaps="false"
            android:textColor="@color/white"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/guideline4"
            app:layout_constraintStart_toStartOf="parent" />

        <Button
            android:id="@+id/noBtn"
            android:layout_width="0dp"
            android:layout_height="@dimen/viewsHeight"
            android:layout_marginStart="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginBottom="10dp"
            android:background="@drawable/rounded_yellow_button"
            android:text="@string/no"
            android:textAllCaps="false"
            android:textColor="@color/white"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="@+id/guideline4" />

        <android.support.constraint.Guideline
            android:id="@+id/guideline4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.5" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/errorIcon"
            android:textSize="60sp"
            android:textColor="@color/red"
            android:tag="icon"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>

</RelativeLayout>

и здесь я установил прозрачный фон для диалога, чтобы показать свой фон

getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

Ответы [ 2 ]

0 голосов
/ 28 мая 2019

Решением может быть добавление bottomPadding для фона диалога точно так же, как радиус.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"></solid>
    <corners android:radius="@dimen/viewsRadius"></corners>
    <padding android:bottom="@dimen/viewsRadius"/>
</shape>
0 голосов
/ 28 мая 2019

Используйте это

Раствор 1

 recyclerView.addItemDecoration(new DividerItemDecoration(getContext(),
                    DividerItemDecoration.VERTICAL));

Раствор 2

Объявите вид, подобный этому, в нижней части макета элемента, установив гравитацию макета или под текстом

    <View
         android:layout_width="match_parent"
         android:layout_height="1dp"
         android:background="@color/grey"></View>
...