我是 android 应用程序开发的新手。我正在尝试创建一个计算器应用程序,我有 2 个问题要问。
1. 如何在LinearLayout中新建一行?它目前看起来像这样:
[文本视图][文本视图][按钮]
我希望它看起来像这样:
[文本视图][文本视图]
[按钮]
这是我的 xml 代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:id="@+id/number1"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/number1" />
<TextView
android:id="@+id/number2"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/number2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_calculate" />
2.如何处理“number1”和“number2”Textviews的总和并将其显示在Main Activity(TextViews所在的位置)上?