java - Android XML 上的图像和 TextView 错误

标签 java android xml android-layout

<强> https://lh4.googleusercontent.com/HN3FW3mfQlcokPsqmRvB2DZkmO4FGPSRRSIkYFnLItsnmG2rLdfC7d8rbJT7kbkudIn7Rp2aWrjHh-8=w1340-h587-rw

我正在制作一个应用程序(在 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/

相关文章:

java - 在依赖管理中导入pom

安卓工作室 : Newly Created Directory Not Appearing In Folders View

iphone - 在 iPhone 中创建 Excel 支持的 XML

java - 按钮在第二次点击android上工作

javascript - 使用 Javascript 或 Jquery 解析 xml 标签属性?

Java 给出看似随机的 StackOverflowError

java - 使用 jsoup 解析表时出现问题

java - 重写一个方法是行不通的

android - 无法在 Android 库文件中找到类

android - 从 android/Java 迁移到 OC/IOS