Android记账本界面实现

 <!--activity_main.xml-->
1
<?xml version="1.0" encoding="utf-8"?> 2 <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context=".MainActivity"> 8 9 <com.google.android.material.appbar.AppBarLayout 10 android:layout_width="match_parent" 11 android:layout_height="wrap_content" 12 android:theme="@style/Theme.Mooc.AppBarOverlay"> 13 14 <androidx.appcompat.widget.Toolbar 15 android:id="@+id/toolbar" 16 android:layout_width="match_parent" 17 android:layout_height="?attr/actionBarSize" 18 android:background="?attr/colorPrimary" 19 app:popupTheme="@style/Theme.Mooc.PopupOverlay" /> 20 21 </com.google.android.material.appbar.AppBarLayout> 22 <include layout="@layout/content_main" /> 23 24 <com.google.android.material.floatingactionbutton.FloatingActionButton 25 android:id="@+id/fab" 26 android:layout_width="wrap_content" 27 android:layout_height="wrap_content" 28 android:layout_gravity="bottom|end" 29 android:layout_margin="@dimen/fab_margin" 30 app:srcCompat="@android:drawable/ic_dialog_info" /> 31 </androidx.coordinatorlayout.widget.CoordinatorLayout>


 <!--content_main.xml-->
1 <?xml version="1.0" encoding="utf-8"?>
 2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     xmlns:app="http://schemas.android.com/apk/res-auto"
 4     android:layout_width="match_parent"
 5     android:layout_height="match_parent"
 6     app:layout_behavior="@string/appbar_scrolling_view_behavior">
 7 
 8     <fragment
 9         android:id="@+id/nav_host_fragment"
10         android:name="androidx.navigation.fragment.NavHostFragment"
11         android:layout_width="0dp"
12         android:layout_height="0dp"
13         app:defaultNavHost="true"
14         app:layout_constraintBottom_toBottomOf="parent"
15         app:layout_constraintLeft_toLeftOf="parent"
16         app:layout_constraintRight_toRightOf="parent"
17         app:layout_constraintTop_toTopOf="parent"
18         app:navGraph="@navigation/nav_graph" />
19     <ListView
20         android:layout_width="match_parent"
21         android:layout_height="match_parent"
22         android:id="@+id/lv_main"
23         />
24 </androidx.constraintlayout.widget.ConstraintLayout>

 <!--list_item.xml-->

1
<?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent"> 5 <TextView 6 android:id="@+id/tv_title" 7 android:layout_width="100dp" 8 android:layout_height="80dp" 9 android:layout_marginLeft="10dp" 10 android:gravity="center" 11 android:singleLine="true" 12 android:textSize="20sp" 13 android:ellipsize="marquee" 14 android:text="costTitle" 15 /> 16 <TextView 17 android:id="@+id/tv_date" 18 android:layout_width="wrap_content" 19 android:layout_height="80dp" 20 android:gravity="center" 21 android:textSize="20sp" 22 android:layout_marginLeft="25dp" 23 android:layout_toRightOf="@+id/tv_title" 24 android:text="costDate" 25 /> 26 27 <TextView 28 android:layout_width="wrap_content" 29 android:layout_height="80dp" 30 android:id="@+id/tv_cost" 31 android:layout_alignParentRight="true" 32 android:textSize="39sp" 33 android:text="60" 34 /> 35 </RelativeLayout>
原文地址:https://www.cnblogs.com/rainbow-1/p/14453828.html