Skip to content

Commit

Permalink
改进界面
Browse files Browse the repository at this point in the history
  • Loading branch information
heyblood committed Jan 21, 2021
1 parent bc6f989 commit 5574906
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 30 deletions.
7 changes: 5 additions & 2 deletions app/src/main/res/layout/earthquake_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
limitations under the License.
-->
<!-- Layout for a list of earthquakes -->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:divider="@null"
android:dividerHeight="0dp"/>
75 changes: 47 additions & 28 deletions app/src/main/res/layout/earthquake_item.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:padding="@dimen/dp_16">
android:paddingStart="16dp"
android:paddingLeft="16dp"
android:paddingEnd="16dp"
android:paddingRight="16dp">

<TextView
android:id="@+id/mag_text"
Expand All @@ -18,47 +20,64 @@
android:textSize="16sp"
tools:text="8.9" />

<TextView
android:id="@+id/place_offset_text"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_weight="2"
tools:text="30km S of" />
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:id="@+id/primary_place_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
tools:text="San Francisco, CA" />
<TextView
android:id="@+id/place_offset_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:maxLines="1"
android:textAllCaps="true"
android:textColor="@color/textColorEarthquakeDetails"
android:textSize="12sp"
tools:text="30km S of" />

<TextView
android:id="@+id/primary_place_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/textColorEarthquakePlace"
android:textSize="16sp"
tools:text="Long placeholder location that should wrap to more than 2 lines of text" />

</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:orientation="vertical">

<TextView
android:id="@+id/date_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="right"
tools:text="May 12, 2008" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textColor="@color/textColorEarthquakeDetails"
android:textSize="12sp"
tools:text="Mar 6, 2010" />

<TextView
android:id="@+id/time_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="right"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textColor="@color/textColorEarthquakeDetails"
android:textSize="12sp"
tools:text="3:00 PM" />

</LinearLayout>


</LinearLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,9 @@
<!-- Magnitude circle color for magnitude over 10 -->
<color name="magnitude10plus">#C03823</color>

<!-- Text color for the details of the earthquake in the list item -->
<color name="textColorEarthquakeDetails">#B4BAC0</color>
<!-- Text color for the primary location of the earthquake in the list item -->
<color name="textColorEarthquakePlace">#2B3D4D</color>

</resources>

0 comments on commit 5574906

Please sign in to comment.