【发布时间】:2017-02-20 03:42:28
【问题描述】:
我试图在 2 个文本视图之间放置两个图像视图,但是当我在我的 Android 设备上通过一个或两个文本视图运行它时,我的图像要么消失,要么似乎被“裁剪”,当我尝试运行时它。有人可以告诉我为什么会这样吗?
<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>
【问题讨论】:
-
您已将所有视图的高度设置为匹配父级,这基本上与您的图像视图重叠
-
在两个 TextView 中使用 wrap_content。并将 adjustViewBounds 和 wrap_content 放入 ImageView
标签: android xml user-interface