почему ориентация видов меняется после установки высоты - PullRequest
0 голосов
/ 07 января 2020

после того, как я установил высоту для моего LinearLayout, мой imageView, который должен на моем LinearLayout, идет за ним, в чем проблема? вот мои коды:

 <RelativeLayout
    android:layout_marginTop="100dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:elevation="10dp"
        android:layout_marginBottom="100dp"
        android:layout_marginTop="100dp"
        android:layout_marginLeft="40dp"
        android:layout_marginRight="40dp"
        android:background="@drawable/login_cardview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </LinearLayout>

    <ImageView
        android:layout_centerHorizontal="true"
        android:src="@mipmap/login_iut_logo"
        android:layout_width="200dp"
        android:layout_height="200dp"/>


</RelativeLayout>

Я хочу, чтобы мой ImageView был на LinearLayout. это работает хорошо, пока не установить высоту для LinearLayout. Я установил высоту, потому что я хотел ее тень.

Я хочу иметь что-то вроде этого: enter image description here

, но после того, как я установил высоту для LinearLayout, она превращается в нечто вроде это: enter image description here

1 Ответ

1 голос
/ 07 января 2020

Если вы хотите, чтобы ваше изображение находилось внутри линейного макета, вы должны вставить его так:

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_marginTop="100dp"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintRight_toRightOf="parent"
  app:layout_constraintTop_toTopOf="parent">

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="40dp"
    android:layout_marginTop="100dp"
    android:layout_marginRight="40dp"
    android:layout_marginBottom="100dp"
    android:elevation="10dp" />


  <ImageView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_centerHorizontal="true"
    android:elevation="10dp" />

</RelativeLayout>

Это должно сработать! (без значительной части вашего кода)

...