java - 线性布局,不按要求出现

标签 java android-studio

所以基本上是 android studio 的新手,我被这个问题困住了,这需要太多时间..

正如标题所说和我提供的图片 - 我想要的结果不匹配.. “x”稍后应该是我的个人信息。我希望模拟器看起来像左图。

感谢任何帮助。

除了主题“DarkactionBar”之外,我的所有东西都可以正常工作。

enter image description here

这是我的代码。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity">


<LinearLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:gravity="center"
    android:orientation="vertical"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintStart_toEndOf="parent"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteY="71dp">


    <ImageView
        android:id="@+id/imageView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:adjustViewBounds="true"
        tools:srcCompat="@tools:sample/avatars" />

    <TextView
        android:id="@+id/CvIntro"
        style="@style/Mitt_CV_STIL"
        android:layout_width="284dp"
        android:layout_height="wrap_content"
        android:text="@string/CvIntro" />

    <Button
        android:id="@+id/Button1"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:onClick="TillCV"
        android:text="@string/button1"


        />


</LinearLayout>


</android.support.constraint.ConstraintLayout>

最佳答案

问题就在这里

tools:srcCompat="@tools:sample/avatars"

tools 命名空间仅用于设计时目的,请阅读此处 https://developer.android.com/studio/write/tool-attributes

关于java - 线性布局,不按要求出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53634207/

相关文章:

java - SonarQube 错误 : Singleton class writes to a field in an Unsynchronized manner

Android Studio 防止代码在粘贴时重新格式化

java - 注册不是封闭类

java - 是否可以将Java11代码编译为Java8字节码并在8上运行?

java - 继承和通用 AsyncTask 的问题

Java 和 SQL - 批处理时出错,必须执行或清除批处理

安卓工作室 : How to uninstall APK (or execute adb command) automatically before Run or Debug?

android - 版本冲突更新为Play-Services 9.4.0 Android Studio 2.2

android-studio - 为什么 Dagger 错误没有出现在编辑器中?

android - crunchPngs 在 Android buildTypes 中意味着什么?