【发布时间】:2018-03-15 23:18:54
【问题描述】:
我创建了一个简单的布局,其中包含一个按钮、一个 TextView 和一个 ImageView(其中带有一个问号)。
<Button
android:background="#f00"
android:textSize="25dp"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Button"
android:id="@+id/button" />
<TextView
android:id="@+id/textViewmas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button"
android:layout_alignLeft="@+id/button"
android:layout_alignStart="@+id/button"
android:text="title "
android:textSize="18dp" />
<ImageView
android:id="@+id/questionmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/textViewmas"
android:layout_alignTop="@+id/textViewmas"
android:layout_alignRight="@+id/button"
android:layout_alignEnd="@+id/button"
app:srcCompat="@drawable/questionmark"/>
The question mark should be a bit more right
我希望图像的右边缘(问号)与按钮的右边缘对齐。 另外顶部和底部应与标题的 textView 的顶部和底部对齐(相同高度)。
为什么图像不在右边缘对齐,而是在左边缘? 我注意到如果我增加标题文本大小(例如 30dp),问题就会消失,但我需要一个小文本大小。
--------编辑:图像是否有最小尺寸,在该尺寸下语句不能正常工作?
【问题讨论】:
-
你到底想要什么,如果你愿意,你可以在油漆中制作图像,然后我会为你设计你想要的。
-
确保您的图像周围没有任何额外的填充。如果图像有任何额外的填充,请使用 Photoshop 或任何其他工具将其删除。或者,检查这张图片,看看它是否合适。 image.flaticon.com/icons/png/512/78/78299.png
-
我已经发布了一个解决方案。让我知道它是否有效
标签: java android xml android-layout alignment