您的位置:首页 > 移动开发 > Android开发

Android案例 装备购买

2017-03-27 20:05 323 查看
一、运行效果图



二、相关代码

<?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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.administrator.myapplication.MainActivity"
    android:weightSum="1"
>

    <ImageView
        android:layout_width="87dp"
        android:layout_height="108dp"
        android:src="@drawable/timg"
        android:layout_gravity="center"
        android:layout_marginTop="60dp"
        
/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="主人快给我买装备吧"
        android:layout_gravity="center_horizontal"
        
/>

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="25dp"
>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
>

            <TextView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:text="生命值"
>

            </TextView>

            <ProgressBar
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="0dp"
                android:layout_weight="3"
                android:layout_marginLeft="20dp"
                android:layout_height="wrap_content"
                
/>

            <TextView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:text="40"
>

            </TextView>

        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
>

            <TextView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:text="攻击力"
>

            </TextView>

            <ProgressBar
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="0dp"
                android:layout_weight="3"
                android:layout_marginLeft="20dp"
                android:layout_height="wrap_content"
                 
/>

            <TextView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:text="200"
>

            </TextView>

        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
>

            <TextView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:text="敏捷"
>

            </TextView>

            <ProgressBar
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="0dp"
                android:layout_weight="3"
                android:layout_marginLeft="20dp"
                android:layout_height="wrap_content"
                 
/>

            <TextView
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:text="40"
>

            </TextView>

        </TableRow>

    </TableLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
>

        <Button
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="主人购买装备"
            android:onClick="click1"
/>

        <Button
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="小宝宝购买装备"
            android:onClick="click2"
/>

    </LinearLayout>

</LinearLayout>







 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: