2017-02-20 6 views
0

Я пытаюсь поместить два изображения между двумя текстовыми видами, но мое изображение либо исчезает, либо кажется «обрезанным», когда я запускаю его на своем Android-устройстве одним или обоими текстовыми представлениями при попытке запустить его , Может ли кто-нибудь сообщить мне, почему это происходит?Попытка разместить ImageView между двумя текстовыми представлениями?

<LinearLayout 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:id="@+id/content_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.annagib.rileycard.Main" 
    tools:showIn="@layout/activity_main"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fontFamily="cursive" 
     android:text="Riley Rayne" 
     android:textColor="#000000" 
     android:textSize="40sp" /> 

    <ImageView 
     android:id="@+id/rye" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/chomie" /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="0" 
     android:fontFamily="cursive" 
     android:text="Poet. Writer. Innovator" 
     android:textColor="#000000" 
     android:textSize="40sp" /> 
</LinearLayout> 
+0

вы установили высоту всего зрения, как матч родителей, которые в основном перекрывают ваш взгляд изображение – Avi

+0

использование wrap_content в обоих TextViews. и поставьте adjustViewBounds и wrap_content в ImageView – Sanny

ответ

0

Вы должны изменить все TextViews и изображение рассматривает высоту и ширину

android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 

И размер TextView слишком велика, что вызывает проблему. Вы должны изменить его размер, чтобы small.As также atrribs

android:layout_width="match_parent" 
    android:layout_height="match_parent" 

отвечает за перекрывания взглядов

Другой способ придать вес элементов. И сделать высоту до 0dp

ie.

<LinearLayout 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:id="@+id/content_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:weightSum="3" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="com.annagib.rileycard.Main" 
tools:showIn="@layout/activity_main"> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:fontFamily="cursive" 
    android:textSize="40sp" 
    android:layout_weight="1" 
    android:textColor="#000000" 
    android:text="Riley Rayne" /> 

<ImageView 
    android:id="@+id/rye" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:src="@drawable/chomie"/> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:fontFamily="cursive" 
    android:layout_weight="1" 
    android:textSize="40sp" 
    android:textColor="#000000" 
    android:text="Poet. Writer. Innovator" /> 
0

Попробуйте это,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/content_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="3" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:fontFamily="cursive" 
      android:text="Riley Rayne" 
      android:textColor="#000000" 
      android:textSize="40sp" /> 

     <ImageView 
      android:id="@+id/rye" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:src="@drawable/chomie" 
      /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:fontFamily="cursive" 
      android:text="Poet. Writer. Innovator" 
      android:textColor="#000000" 
      android:textSize="40sp" /> 
    </LinearLayout>