Java 线性布局,不按需要显示

Java 线性布局,不按需要显示,java,android-studio,Java,Android Studio,所以对于android studio来说基本上是一个新手,我被这个问题困住了,这个问题花费了太多的时间 正如标题和我提供的形象所说,我想要的结果并不匹配。。 “x”应该是我以后的个人信息。我希望仿真器看起来像左图 感谢您的帮助 除了主题“DarkactionBar”之外,我什么都做了。 这是我的密码 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns

所以对于android studio来说基本上是一个新手,我被这个问题困住了,这个问题花费了太多的时间

正如标题和我提供的形象所说,我想要的结果并不匹配。。 “x”应该是我以后的个人信息。我希望仿真器看起来像左图

感谢您的帮助

除了主题“DarkactionBar”之外,我什么都做了。

这是我的密码

<?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"
工具名称空间仅用于设计时目的,请阅读此处

您可以从下面的代码中替换xml布局。 希望这会有所帮助

除了主题“DarkactionBar”之外,我什么都做了。


您已经在res/values文件夹下更改了colors.xml。在colors.xml中,您需要根据需要的颜色更改colorPrimary、colorPrimaryDark、colorAccent等


其中colorPrimary是工具栏颜色,color accent是查看项目颜色。

该图像几乎只是一个示例,我不想提供我自己的照片供社区查看。我确实尝试了我自己的附加照片,但仍然不起作用。你必须使用应用程序名称空间->
app:srcCompat=“@drawable/your_image”
`我试过了。不知何故,我得到了img和所有的工作,但不是主题。有任何提示吗?单击sdk版本旁边的图标并选择您的主题您如何定义应用程序主题?要显示清单和样式文件吗?
<?xml version="1.0" encoding="utf-8"?>
<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:gravity="center"
    tools:context=".MainActivity">

    <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"
        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>