猜纸牌游戏之一 界面设计和资源文件的设计
【摘要】
视频课:https://edu.csdn.net/course/play/7621
本游戏实现安卓手机下的猜纸牌游戏,由电脑和玩家一起玩,进行随机扑克的猜测,得分!
一:定义字符串的资源文件
<?xml version="1.0" encoding="utf-8"?><resources> <str...
视频课:https://edu.csdn.net/course/play/7621
本游戏实现安卓手机下的猜纸牌游戏,由电脑和玩家一起玩,进行随机扑克的猜测,得分!
一:定义字符串的资源文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">纸牌游戏</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="show1">请单机获取按钮,来得到你的牌,并通过输入你现有的牌的数字并点击确定来进行游戏。每张纸牌只能使用1次!</string>
<string name="tishi">请输入你的用户名!</string>
<string name="ok">确定</string>
<string name="gameguize"></string>
</resources>
主界面
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backe"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/ivcpu"
android:layout_width="105dp"
android:layout_height="150dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/img16" />
<ImageView
android:id="@+id/ivcm"
android:layout_width="105dp"
android:layout_height="150dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="64dp"
android:src="@drawable/img16" />
<EditText
android:id="@+id/edtcm"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignBottom="@+id/ivcm"
android:layout_toLeftOf="@+id/ivcpu"
android:background="#00ff00"
android:ems="10"
android:inputType="number"
android:textSize="40sp" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/tvshow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/ivcm"
android:layout_alignLeft="@+id/ivcm"
android:layout_alignTop="@+id/ivcpu"
android:layout_toLeftOf="@+id/btnget"
android:text="@string/show1"
android:textColor="#ffffff"
android:textSize="20sp" />
<Button
android:id="@+id/buttonok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/edtcm"
android:layout_alignLeft="@+id/edtcm"
android:text="@string/ok" />
<ListView
android:id="@+id/lvcmsz"
android:layout_width="80dp"
android:layout_height="200dp"
android:background="#ffffff"
android:layout_alignTop="@+id/ivcm"
android:layout_toRightOf="@+id/buttonok" >
</ListView>
<Button
android:id="@+id/btnget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvshow"
android:layout_toLeftOf="@+id/lvcmsz"
android:text="获取" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
>
<TextView
android:id="@+id/tvshow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="42dp"
android:text="@string/show1"
android:textSize="20sp" />
<EditText
android:id="@+id/edtcm"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignLeft="@+id/ivcm"
android:layout_below="@+id/ivcm"
android:layout_marginTop="50dp"
android:background="#00ff00"
android:maxLength="2"
android:ems="10"
android:inputType="number"
android:textSize="40sp" />
<Button
android:id="@+id/buttonok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/edtcm"
android:layout_toRightOf="@+id/edtcm"
android:text="@string/ok" />
<Button
android:id="@+id/btnget"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignTop="@+id/ivcpu"
android:layout_marginTop="27dp"
android:layout_toRightOf="@+id/ivcm"
android:background="@drawable/pk"
android:text="PK"
android:textColor="#ffff00"
android:textSize="70px"/>
<ImageView
android:id="@+id/ivcm"
android:layout_width="105dp"
android:layout_height="150dp"
android:layout_alignLeft="@+id/tvshow"
android:layout_alignTop="@+id/ivcpu"
android:src="@drawable/img16" />
<ImageView
android:id="@+id/ivcpu"
android:layout_width="105dp"
android:layout_height="150dp"
android:layout_below="@+id/tvshow"
android:layout_marginTop="15dp"
android:layout_toRightOf="@+id/btnget"
android:src="@drawable/img16" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
>
<TextView
android:id="@+id/tvshow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="42dp"
android:text="@string/show1"
android:textSize="20sp" />
<EditText
android:id="@+id/edtcm"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignLeft="@+id/ivcm"
android:layout_below="@+id/ivcm"
android:layout_marginTop="50dp"
android:background="#00ff00"
android:maxLength="2"
android:ems="10"
android:inputType="number"
android:textSize="40sp" />
<Button
android:id="@+id/buttonok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/edtcm"
android:layout_toRightOf="@+id/edtcm"
android:text="@string/ok" />
<Button
android:id="@+id/btnget"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignTop="@+id/ivcpu"
android:layout_marginTop="27dp"
android:layout_toRightOf="@+id/ivcm"
android:background="@drawable/pk"
android:text="PK"
android:textColor="#ffff00"
android:textSize="70px"/>
<ImageView
android:id="@+id/ivcm"
android:layout_width="105dp"
android:layout_height="150dp"
android:layout_alignLeft="@+id/tvshow"
android:layout_alignTop="@+id/ivcpu"
android:src="@drawable/img16" />
<ImageView
android:id="@+id/ivcpu"
android:layout_width="105dp"
android:layout_height="150dp"
android:layout_below="@+id/tvshow"
android:layout_marginTop="15dp"
android:layout_toRightOf="@+id/btnget"
android:src="@drawable/img16" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/backe"
>
<TextView
android:id="@+id/tvtishi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="纸牌游戏!"
android:textSize="30sp"
android:textColor="#ffffff"
/>
<EditText
android:id="@+id/edtusename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/tishi"
android:maxLength="5"
android:text=""
android:textColor="#ffffff"
/>
<Button
android:id="@+id/btnlogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登陆"
android:textColor="#ffffff"
/>
</LinearLayout>
文章来源: aaaedu.blog.csdn.net,作者:tea_year,版权归原作者所有,如需转载,请联系作者。
原文链接:aaaedu.blog.csdn.net/article/details/51737167
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)