android计算器设计本人学习android有一个多月了,在学习期间为了对所学的知识进行应用,因而设计了一个简单的计算器,现在通过本文与大家一起分享。由于本人水平有限,因此设计的计算器可能有着一部分的BUG,如发现BUG请联系我,谢谢! QQ:,我们都要设计一个图标,可以说图标是应用程序的名片,好的图标能够很快地吸引用户。关于如何设计图标,在网上可以查询相关文件进行学习,在这不多做讲述,本人在网上寻找了一个图标作为计算器应用的图标,图标如下所示。由于不同的android手机有着不同的分辨率,将不同分辨率的图标图片放置在相应位置,如下图所示。drawable-hdpi中放置分辨率最高的图标,drawable-ldpi中放置分辨率中等的图标,drawable-hdpi中放置分辨率最低的图标。图标图片大小的要求如下:,修改情况如下:<applicationandroid:icon="***@drawable/calculator"android:label="***@string/app_name">其他设置保持不变。,代码为:<stringname="app_name">计算器</string。结果如下图所示:按钮放置以及界面编排界面设计应该尽量简洁而美观,应该具有良好的交互性。因本人水平有限,所以设计的界面不是很完美,望请见谅。最终设计的计算器界面情况如下所示:整个界面的布局为LinearLayout,按钮的布局为TableLayout。另外需要对EditText和Button的一些属性进行相关设置,以使得它们满足我们的需要。,代码如下所示:<?xmlversion=""encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas./apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="#880000"android:paddingTop="50px"><EditText android:id="@+id/editText" android:gravity="left" android:text="" android:textSize="37px" android:layout_height="150px" android:layout_width="fill_parent" android:layout_marginBottom="20px" android:layout_marginLeft="10px" android:layout_marginRight="10px" android:editable="false" android:cursorVisible="false" ></EditText><EditText android:id="@+id/editText1" android:gravity="left" android:text="" android:textSize="40px" android:layout_height="80px" android:layout_width="fill_parent" android:layout_marginBottom="30px" android:layout_marginLeft="10px" android:layout_marginRight="10px" android:editable="false" android:cursorVisible="false" android:focusable="false" ></EditText> <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="0,1,2,3,4" > <TableRow> <Button android:id="@+id/buttom7" android:layout_margin="3px" android:text="7" android:textSize="40px" android:focusable="false" /> <Button an
android计算器设计. 来自淘豆网m.daumloan.com转载请标明出处.