您好,很抱歉没有在此页面上添加图片,我的信誉还不够
This is how it's supposed to look和this是如何在recyclerView中显示的,正如您所看到的,我想让图像位于左侧,而居中的文本位于右侧,如何实现呢?< / p>
这是项目布局的代码
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="wrap_content"
android:padding="10dip"
>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imgRowCompany"
android:layout_width="115dp"
android:layout_height="80dp"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:clickable="false"
android:src="@drawable/library_icon"
android:visibility="visible"
app:civ_border_color="@color/Blue"
app:civ_border_width="2.5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txtRowCompanyName"
android:layout_width="0dp"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:text="CompanyName"
android:textColor="#000000"
android:textSize="25sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgRowCompany"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
recyclerAdapter代码:
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> {
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View view = layoutInflater.inflate(R.layout.recycler_item,parent,false);
ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
}
@Override//Number od items to be returned
public int getItemCount() {
return 10;
}
static class ViewHolder extends RecyclerView.ViewHolder {
CircleImageView imageRowCompany;
TextView companyName;
public ViewHolder(@NonNull View itemView) {
super(itemView);
imageRowCompany=itemView.findViewById(R.id.imgRowCompany);
companyName=itemView.findViewById(R.id.txtRowCompanyName);
}
}
}
还有recyclerView代码:
<androidx.constraintlayout.widget.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=".CompanyLibrary"
>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
任何帮助将不胜感激,谢谢!
答案 0 :(得分:2)
您发布的图像位于RTL设备上。端到端并开始以预期的方式工作,如果要以自己的方式显示,请使用
app:layout_constraintRight_toRightOf="parent" instead of
app:layout_constraintEnd_toEndOf="parent"
和
app:layout_constraintLeft_toLeftOf="parent" instead of
app:layout_constraintStart_toStartOf="parent"