我已经查看了广告列表,并且LinearLayout没有填充整个屏幕宽度,检查了所有代码,并且我不明白我在哪里弄错了。这是我的LinearLayout的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
android:id="@id/advertisement_list_container"
android:paddingTop="0.0dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@id/advertisement_list_datetime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_margin_horizontal"
android:paddingTop="@dimen/small_listing_margin"
android:paddingRight="@dimen/activity_margin_horizontal"
android:paddingBottom="@dimen/small_listing_margin"
android:layout_marginBottom="@dimen/listing_margin"
android:text="@string/advertisement_list_datetime"
style="@style/TextWhiteNormalBoldGreyBackground" />
<LinearLayout
android:orientation="vertical"
android:paddingLeft="@dimen/activity_margin_horizontal"
android:paddingRight="@dimen/activity_margin_horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@id/advertisement_list_from_city"
android:layout_marginLeft="@dimen/listing_margin"
android:text="@string/advertisement_list_from_city"
style="@style/TextNormalBold" />
<TextView
android:id="@id/advertisement_list_tire"
android:layout_marginLeft="@dimen/tire_margin"
android:text="@string/advertisement_list_tire"
style="@style/TextNormalBold" />
<TextView
android:id="@id/advertisement_list_to_city"
android:layout_marginLeft="@dimen/tire_margin"
android:text="@string/advertisement_list_to_city"
style="@style/TextNormalBold" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin_vertical">
<ImageView
android:id="@id/advertisement_list_user_avatar"
android:layout_width="@dimen/avatar_result_size_width"
android:layout_height="@dimen/avatar_result_size_height"
android:src="@drawable/ic_default_avatar" />
<LinearLayout
android:gravity="center_vertical"
android:orientation="vertical"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_marginLeft="@dimen/listing_margin"
android:layout_weight="1.0">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@id/advertisement_list_user_name"
android:text="@string/advertisement_list_user_name"
style="@style/TextDarkBlueNormalBold" />
<TextView
android:id="@id/advertisement_list_user_age"
android:text="@string/advertisement_list_user_age"
android:layout_marginLeft="@dimen/small"
style="@style/TextGreyNormal" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="@dimen/text_normal"
android:layout_height="fill_parent"
android:layout_marginRight="@dimen/margin_small"
android:src="@drawable/ic_star_gold_no_border"
android:scaleType="fitCenter" />
<TextView
android:id="@id/advertisement_list_user_rating"
android:text="@string/advertisement_list_user_rating"
style="@style/TextNormalBold" />
<TextView
android:id="@id/advertisement_list_user_rate"
android:layout_marginLeft="@dimen/margin_micro"
android:text="@string/advertisement_list_user_rate"
style="@style/TextGreyNormal" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="@dimen/text_normal"
android:layout_height="fill_parent"
android:layout_marginRight="@dimen/small"
android:src="@drawable/ic_car_blue"
android:scaleType="fitCenter" />
<TextView
android:id="@id/advertisement_list_user_car"
android:layout_marginRight="@dimen/small"
android:text="@string/advertisement_list_user_car"
style="@style/TextNormalBold" />
<TextView
android:id="@id/advertisement_list_user_car_y"
android:text="@string/advertisement_list_user_car_y"
style="@style/TextGreyNormal" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="@dimen/text_normal"
android:layout_height="fill_parent"
android:layout_marginRight="@dimen/small"
android:tint="@color/text_dark_blue"
android:src="@drawable/ic_phone"
android:scaleType="fitCenter" />
<TextView
android:id="@id/advertisement_list_user_phone"
android:layout_marginRight="@dimen/small"
android:text="@string/advertisement_list_user_phone"
style="@style/TextNormalBold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin_vertical">
<LinearLayout
android:orientation="vertical"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_weight="2.0">
<TextView
android:gravity="center_horizontal"
android:id="@id/advertisement_list_free_seats"
android:layout_width="fill_parent"
android:text="@string/advertisement_list_free_seats"
style="@style/TextDarkBlueMediumBold" />
<TextView
android:gravity="center_horizontal"
android:id="@id/advertisement_list_free_seats"
android:layout_width="fill_parent"
android:text="@string/advertisement_list_free_seats"
android:lines="2"
style="@style/TextDarkBlueSmall" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:background="@color/transparent"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_weight="2.0">
<TextView
android:gravity="center_horizontal"
android:id="@id/advertisement_list_price"
android:layout_width="fill_parent"
android:text="@string/advertisement_list_price"
style="@style/TextDarkBlueMediumBold" />
<TextView
android:gravity="center_horizontal"
android:id="@id/advertisement_list_ride_price"
android:layout_width="fill_parent"
android:text="@string/advertisement_list_ride_price"
android:lines="2"
style="@style/TextDarkBlueSmall" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:background="@drawable/divider"
android:contentDescription="@string/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
这就是我在应用程序中看到的结果:https://imgur.com/a/eKv1hHi
因此,广告必须填满整个屏幕宽度。
答案 0 :(得分:0)
将主要LinearLayout
更改为RelativeLayout
,并解决了我的问题!