Вы пытались сначала инициализировать модель просмотра, а затем передать ее в представление?
public View2(View2ViewModel vm)
{
InitializeComponent();
Messenger.Default.Register<NotificationMessage<int>>(this, (m) => NotificationMesageReceived(m, m.Content));
}
private void NotificationMesageReceived(NotificationMessage<int> msg, int divisionIdnt)
{
if (msg.Notification == "SearchCred")
{
var vm = new View2ViewModel();
vm.DivisionIdnt = divisionIdnt;
var findCredentialView = new View2(vm);
findCredentialView.ShowDialog();
}
}
Я думаю, что установка android:layout_height="match_parent"
на ConstraintLayout
решит вашу проблему.
использовать этот макет
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/roundable_bg">
<android.support.v7.widget.RecyclerView
android:id="@+id/wv_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bt_ok"
android:background="@android:color/white"
/>
<TextView
android:id="@+id/bt_ok"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:padding="12dp"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:background="@drawable/button_selector"
android:gravity="center"
android:textColor="@android:color/black"
android:text="@string/ok" />
</RelativeLayout>
В вашем Recyclerview
установить
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
удалить
app:layout_constraintHeight_max="350dp"
android:maxHeight="350dp"
Это простое изменение заставляет его работать.
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewFolderList"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHeight_default="wrap"
app:layout_constraintBottom_toTopOf="@+id/imgViewClose2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView1" />
Спасибо всем, кто пытался мне помочь.
У меня была эта проблема. В конце концов я отказался от использования ConstraintLayout здесь и вернулся к RelativeLayout - легко и сработало как шарм.
ConstraintLayout - это здорово, но иногда лучшим решением является старая школа.
попробуйте использовать minWidth
, minHeight
и maxWidth
, maxHeight
в корневом макете диалога.