【发布时间】:2019-07-10 23:40:49
【问题描述】:
强文本 左边是我手机的图片,右边是android studio。我想知道为什么在我的手机上看起来不像在 android studio 上。
我的项目.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_margin="20dp"
app:cardBackgroundColor="@color/colorSecurity">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@mipmap/ic_database"/>
</LinearLayout>
<TextView
android:id="@+id/tvOption"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:gravity="center_vertical"
android:text="OPCIÓN 1"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
我在活动课上的回收员
recyclerOptions = findViewById(R.id.recyclerOptions);
recyclerOptions.setHasFixedSize(true);
LinearLayoutManager lm = new LinearLayoutManager(this);
lm.setOrientation(RecyclerView.VERTICAL);
recyclerOptions.setLayoutManager(lm);
【问题讨论】:
-
我投票决定将此问题作为题外话结束,因为它没有遵循How to Ask 和minimal reproducible example 中概述的准则。也不要在问题中放链接,解释问题,你尝试了什么,失败了什么,你还想要什么,...
-
您好 Jhan,我认为在您的 item.xml 中,您的 cardview 中,您将其作为宽度的包装内容。将其更改为 matchparent
-
请分享您的列表项布局,以便我们提供帮助。
-
我分享了我的代码,希望你能帮助我,谢谢。
标签: android android-recyclerview android-cardview