大概步骤建立几个Activity并将图片分别关联到其中,并进行布局操作,一个是主要的界面,另一个是进入Shop后的界面,操作的具体代码和结果如下:
代码:
activity_char.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
- android:layout_height="match_parent">
- <TextView
- android:id="@+id/name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10dp"
- />
- <ImageView
- android:id="@+id/iv"
- android:layout_width="120dp"
- android:layout_height="150dp"
- android:layout_gravity="center"
- android:layout_marginTop="50dp"
- android:background="@drawable/soldier76"/>
- <TextView
- android:id="@+id/CN"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginTop="5dp"
- android:textSize="23sp"
- android:text="Soldier76"
- />
- <TextView
- android:id="@+id/status"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginTop="5dp"
- android:layout_marginBottom="3dp"
- android:text="Wonderful"
- android:textColor="#7CFC00"/>
- <TableLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center">
- <TableRow
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Health"
- android:textSize="20sp"
- android:layout_weight="1"
- />
- <ProgressBar
- android:id="@+id/pro_health"
- style="@style/Widget.AppCompat.ProgressBar.Horizontal"
- android:layout_weight="2"
- android:indeterminateTint="#7CFC00"
- android:indeterminateTintMode="src_atop"/>