簡體   English   中英

使用約束布局無法在指南下方放置文本視圖

[英]Using Constraint layout not able to place a textview below guideline

我正在嘗試在指南下方放置一個 TextView。 我試過如下,

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/linearLayout2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
<TextView
    android:id="@+id/package_name_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@color/black"
    android:textSize="20sp"
    android:text="Package Name"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintTop_toBottomOf="@id/start_guideline"
    />
    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/start_guideline"
        android:layout_width="wrap_content"
        android:orientation="horizontal"
        android:layout_height="wrap_content"
        app:layout_constraintGuide_percent="0.05"/>
    <TextView
        android:id="@+id/sub_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Subscription"
        android:textColor="@color/black"
        android:textSize="15sp"
        app:layout_constraintTop_toBottomOf="@id/package_name_text_view"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

我的包名稱 TextView 未顯示在指南下方...我是使用 ConstraintLayout 的新手。 無法找到我的錯誤......任何人都可以幫助我解決這個問題。

刪除constraintTop_toTopOf in package_name_text_view

    <androidx.constraintlayout.widget.ConstraintLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    <TextView
        android:id="@+id/package_name_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/black"
        android:textSize="20sp"
        android:text="Package Name"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/start_guideline"
        />


    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/start_guideline"
        android:layout_width="wrap_content"
        android:orientation="horizontal"
        android:layout_height="wrap_content"
        app:layout_constraintGuide_percent="0.05"/>
    <TextView
        android:id="@+id/sub_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Subscription"
        android:textColor="@color/black"
        android:textSize="15sp"
        app:layout_constraintTop_toBottomOf="@id/package_name_text_view"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM