【发布时间】:2020-09-06 03:36:24
【问题描述】:
所以我想要一个 ImageView,它是一个语音气泡和一个按钮,它是我活动中的企鹅。 penguinbutton 应该在右下角,speechbubble ImageView 应该在企鹅上方的左边一点点。 当我将所有宽度和高度设置为固定值时,它工作正常,但是一旦我在另一台设备上打开它,它就会全部调整大小。 我的问题是我找不到任何方法让这些元素按照我想要的方式适应不同的屏幕尺寸。 下面是一些代码,它确实在每个设备上调整了它们的大小,但它调整了 50/50 的大小,因此 ImageView 占据了上屏的 50%,而按钮占据了下屏的 50%。 我不知道如何在不同屏幕上调整大小的同时将它们保持在某个位置。 欢迎任何帮助。
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/ein_hintergrund2"
tools:context=".MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:srcCompat="@drawable/speechbubble"
android:id="@+id/klick_textView"
android:layout_marginBottom="9dp"
android:contentDescription="@string/todo"/>
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/start_button"
android:background="@drawable/pinguin"/> </LinearLayout>
【问题讨论】:
标签: java android android-studio button