首先,抱歉我的英语不好 我有一个像这样的xml布局的recyclerview
<layout 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">
<data>
<variable
name="township"
type="com.test.feature.Area" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="horizontal"
android:paddingTop="@dimen/_10sdp"
android:paddingBottom="@dimen/_10sdp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@{township.name}"
android:textColor="@color/agent_list_gray_1"
android:textSize="@dimen/_15ssp" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/btnRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
我将文本设置为Adapter类中的textview,这就是我想要的what I want
但是,如果我使用数据绑定此行
机器人:文字= “@ {} township.name”
我有这个layout_weight is incorrect
那么有人知道我的代码有什么问题吗?
还有另一种存档这种UI的方法,但我真的想知道为什么这不起作用
您是否可以使用RelativeLayout并将Textview设置为parentLeft并将EditText视图设置为父权限的间距?
有点奇怪!因为我实现了你的代码并且它有效。也许尝试将它包装在父视图中,如下所示(我这样做):
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/backgroundOrange"
android:orientation="horizontal"
android:paddingTop="@dimen/_10sdp"
android:paddingBottom="@dimen/_10sdp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@{township.name}"
android:textColor="@color/textPrimary"
android:textSize="15dp"/>
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/btnRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
让我知道它是否有效。