Android 是否尝试在两个文本视图之间放置ImageView?
我试图将两个图像视图放在两个文本视图之间,但当我在Android设备上运行图像时,我的图像要么消失,要么似乎被“剪切掉”,当我尝试运行图像时,其中一个或两个文本视图都在运行图像。有人能告诉我为什么会这样吗Android 是否尝试在两个文本视图之间放置ImageView?,android,xml,user-interface,Android,Xml,User Interface,我试图将两个图像视图放在两个文本视图之间,但当我在Android设备上运行图像时,我的图像要么消失,要么似乎被“剪切掉”,当我尝试运行图像时,其中一个或两个文本视图都在运行图像。有人能告诉我为什么会这样吗 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools
<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>
您应该将所有文本视图和图像视图的高度和宽度更改为
android:layout_width="wrap_content"
android:layout_height="wrap_content"
文本视图的大小太大,导致了问题。你应该把它的尺寸改小。还有肋骨
负责视图的重叠
另一种方法是赋予元素权重。并使高度达到0dp
即
试试这个
<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>
您已将所有视图的高度设置为匹配父视图,该父视图基本上与图像视图重叠。请在两个文本视图中使用换行符内容。并将adjustViewBounds和wrap_内容放在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"
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" />
<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>