我正在制作一个应用程序(在 Android Studio 中),并且发生了一些奇怪的错误,例如图像之前留有很大的空间以及图像顶部出现的文本。我进行了研究,但没有任何解决方案有帮助。
内容.XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity$PlaceholderFragment">
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"/>
<TextView android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/logo"
android:text="Welcome!"
android:textSize="35dp"
android:layout_centerInParent="true"
android:textColor="#fff"
android:gravity="center_horizontal"/>
</RelativeLayout>
</ScrollView>
PS< 我在 Android Studio 中的抽屉导航模板上还遇到了另一个问题,当单击“示例操作”按钮时,出现的透明圆圈一侧呈方形。谢谢:)
最佳答案
那是因为您使用的是相对布局。我建议您将 Textview 和 Imageview 封装在垂直方向的 LinearLayout 中。希望对您有帮助。
关于java - Android XML 上的图像和 TextView 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31120164/