TextView不会粘在右边
我想将TextView
粘贴到右上方。TextView不会粘在右边
我的代码是:
<?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="Test.test.MainActivity">
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="42dp"/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_marginRight="0dp"
android:text="@string/Title1"
android:textSize="30dp" />
</android.support.constraint.ConstraintLayout>
我尝试设置TextView
:
android:layout_alignParentRight="true"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
但没有什么工作,TextView
留在左上角。
有人有解决方案的想法吗?
UPDATE:
如何坚持留下TextView
另一个TextView
是坚持正确的家长吗?
我尝试设置怀特并没有什么..
<TextView android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_weight="0"
android:layout_height="42dp"
app:layout_constraintRight_toRightOf="parent"
android:text="@string/Title1"
android:textSize="30dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="42dp"
app:layout_constraintRight_toRightOf="parent"
android:text="@string/Title2"
android:textSize="30dp" />
我想textView2将坚持留textView1。
找到解决更新 我只是在textview2
应用程序设置:layout_constraintBaseline_toBaselineOf = “@ + ID/textView1”
应用:layout_constraintEnd_toStartOf = “@ + ID/textView1”
谢谢,
塔尔
回答:
在约束布局中,TextView
权约束集父布局右对齐向右
添加以下约束你TextView
app:layout_constraintRight_toRightOf="parent"
这样
<TextView android:id="@+id/textViewHowMuchSigned"
android:layout_width="wrap_content"
android:layout_height="42dp"
app:layout_constraintRight_toRightOf="parent"
android:text="@string/Title"
android:textSize="30dp" />
以上是 TextView不会粘在右边 的全部内容, 来源链接: utcz.com/qa/260119.html