元素始终显示在屏幕顶部。我尝试了不同的方法来解决但运气不好。我想将元素放在屏幕的任何位置。这是碎片屏幕。
<FrameLayout 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"
tools:context="myapp.com.myapp1.fragments.AddPeopleFragment">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="159dp"
android:text="three"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginStart="110dp"
android:layout_marginTop="167dp" />
</FrameLayout>
答案 0 :(得分:0)
你有没有注意到这些代码?
"android:layout_alignParentTop="true"
android:layout_alignParentStart="true""
如果你想使用绝对布局,不要打扰这些代码;
例如:
<FrameLayout 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"
tools:context="myapp.com.myapp1.fragmants.FragmantAddPeople">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="159dp"
android:text="three"
android:layout_marginStart="110dp"
android:layout_marginTop="167dp" />
</android.support.constraint.ConstraintLayout>
您可以通过更改absoluteX和absoluteY的dp值将项目(以防万一)放在任何地方;``