我设计了一个带有地图片段和recyclerView的布局.每个recyclerView项都是cardview(我已指定给出xml布局).
问题是RecyclerView项目没有填充屏幕宽度. img在这里
我试图将layout_width更改为fill_parent,match_parent但它无能为力
这是每个项目的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:id="@+id/cardView">
<LinearLayout
android:id="@+id/locationItemView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="120px"
android:layout_height="120px"
android:id="@+id/imgIcon"
android:background="@drawable/image_bg"
android:layout_margin="5dp"
android:scaleType="fitCenter"
android:adjustViewBounds="true" />
<LinearLayout
android:id="@+id/layoutInfo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txtName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Location Name"
android:textColor="#d5c645"
android:textStyle="bold"
android:textSize="20dp"
android:padding="3dp" />
<TextView
android:id="@+id/txtAddress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Location Address"
android:textSize="16dp"
android:padding="3dp" />
<TextView
android:id="@+id/txtDistance"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:text="Location Distance"
android:textSize="14dp"
android:textStyle="italic"
android:padding="2dp"
android:textAlignment="viewEnd" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
和main_layout
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud)